# HG changeset patch # User František Kučera # Date 1580423269 -3600 # Node ID 5a63bf594f53071c098ed1993498241d3f013075 # Parent a680bcd946cd1856a04ec208bf9e9624f18260db streamlet examples: xpath: support XInclude (like in relpipe-tr-xmltable) diff -r a680bcd946cd -r 5a63bf594f53 streamlet-examples/xpath.cpp --- a/streamlet-examples/xpath.cpp Thu Jan 30 18:04:10 2020 +0100 +++ b/streamlet-examples/xpath.cpp Thu Jan 30 23:27:49 2020 +0100 @@ -48,6 +48,8 @@ * - raw-xml-attribute-wrapper-uri * - raw-xml-attribute-wrapper-prefix * + * XInclude processing may be turned on using: --option xinclude true + * * TODO: more OOP, move to separate repository, proper CMake project, clean-up, stabilize API */ class XPathStreamlet : public Streamlet { @@ -65,6 +67,12 @@ for (Option o : getOptions(std::wregex(L"xmlns"), std::wregex(L"([^:]+):(.*)"))) ns[toBytes(o.valueMatch[1])] = toBytes(o.valueMatch[2]); } + bool xinclude = false; + + void findXIncludeOptions() { + for (Option o : getOptions(L"xinclude")) xinclude = o.value == L"true"; + } + std::wstring rawXmlNodeListWrapperName; std::wstring rawXmlNodeListWrapperUri; std::wstring rawXmlNodeListWrapperPrefix; @@ -163,6 +171,7 @@ findXmlnsInEnvironment(); findXmlnsInOptions(); findRawXmlOptions(); + findXIncludeOptions(); std::vector oam; @@ -184,6 +193,7 @@ try { xmlpp::DomParser parser; parser.parse_file(toBytes(getCurrentFile())); + if (xinclude) parser.get_document()->process_xinclude(true); xmlpp::Element* root = parser.get_document()->get_root_node(); for (XPathAttribute xpathAttribute : xpathAttributes) {