| operator + overloading == HOT |
[Jun. 4th, 2004|04:36 pm] |
| [ | Mood |
| | giddy | ] | Last night, after trying to figure out why Xalan-C++ 1.8 was not behaving when used in my SiteMapper program on Windows, saurik showed me his syntax for XPath that is in his Menes C++ Library Thingy: *document/"page"/"section"/"list". Yes, that's the division operator used with XML nodes and strings, hot! So rather than trying more with evil and verbose Xalan/Xerces XPath, I decided to change my program to use his syntax. This resulted in a change from code like this:
XalanSourceTreeInit init;
XalanSourceTreeDOMSupport support;
XalanSourceTreeParserLiaison liaison;
XPathEvaluator evaluator;
support.setParserLiaison(&liaison);
XalanDOMString file(siteMap.c_str());
LocalFileInputSource source(file.c_str());
XalanDocument* document = liaison.parseXMLStream(source);
if (document == 0) return;
XalanNode* list = evaluator.selectSingleNode(support, document,
XalanDOMString("/page/section/list").c_str());
if (list == 0) return;
comment << evaluator.evaluate(support, document,
XalanDOMString("comment()").c_str())->str();
to clean and simple code like this:
ext::Handle<xml::Document> document(xml::Parse(siteMap));
ext::Handle<xml::Node> list(*document/"page"/"section"/"list");
comment = *document/"comment()";
which does basically the same thing (comment was changed from an ostringstream to just a string). We then went on to get it working right and solve the fun link errors on FreeBSD. |
|
|