Freelance software grandad
software created
extended or repaired
Follow me on Mastodon
Applications, Libraries, Code
Talks & Presentations
Added a few little tweaks to the XPath grammar this evening. Just have to walk the abstract syntax tree the parser creates and build a nice little XPath object to do the work. Course, I have to write the code that would use ...
Also fixed XMLBaseSupport so it works properly in the face of the URLs which don't end with a / character. There are some implicit std::string dependencies in there too, but I'm not overly fussed about that right now. Using the XMLBaseSupport class is simplicity itself - create an instance, call it in your startElement and endElement handlers, and use its makeAbsolute member function when you want to a URI referenced relative to the current xml:base. Here's the business part of a little example that prints xlink:hrefs,
void hrefPrinter::startElement(const std::string&, const std::string& localName, const std::string&, const SAX::Attributes& atts) { xmlbaseTracker_.startElement(atts); std::string href = atts.getValue("http://www.w3.org/1999/xlink", "href"); if(href.empty()) return; std::cout << "href '" << href << "' resolves to the URI '" << xmlbaseTracker_.makeAbsolute(href) << "'" << std::endl; } // startElement void hrefPrinter::endElement(const std::string&, const std::string& localName, const std::string&) { xmlbaseTracker_.endElement(); } // endElement
Freelance software grandad
software created
extended or repaired
Follow me on Mastodon
Applications, Libraries, Code
Talks & Presentations