equal
deleted
inserted
replaced
46 * - raw-xml-nodelist-wrapper-prefix |
46 * - raw-xml-nodelist-wrapper-prefix |
47 * - raw-xml-attribute-wrapper-name |
47 * - raw-xml-attribute-wrapper-name |
48 * - raw-xml-attribute-wrapper-uri |
48 * - raw-xml-attribute-wrapper-uri |
49 * - raw-xml-attribute-wrapper-prefix |
49 * - raw-xml-attribute-wrapper-prefix |
50 * |
50 * |
|
51 * XInclude processing may be turned on using: --option xinclude true |
|
52 * |
51 * TODO: more OOP, move to separate repository, proper CMake project, clean-up, stabilize API |
53 * TODO: more OOP, move to separate repository, proper CMake project, clean-up, stabilize API |
52 */ |
54 */ |
53 class XPathStreamlet : public Streamlet { |
55 class XPathStreamlet : public Streamlet { |
54 private: |
56 private: |
55 xmlpp::Node::PrefixNsMap ns; |
57 xmlpp::Node::PrefixNsMap ns; |
61 } |
63 } |
62 |
64 |
63 void findXmlnsInOptions() { |
65 void findXmlnsInOptions() { |
64 for (Option o : getOptions(std::wregex(L"xmlns[:_](.*)"))) ns[toBytes(o.nameMatch[1])] = toBytes(o.value); |
66 for (Option o : getOptions(std::wregex(L"xmlns[:_](.*)"))) ns[toBytes(o.nameMatch[1])] = toBytes(o.value); |
65 for (Option o : getOptions(std::wregex(L"xmlns"), std::wregex(L"([^:]+):(.*)"))) ns[toBytes(o.valueMatch[1])] = toBytes(o.valueMatch[2]); |
67 for (Option o : getOptions(std::wregex(L"xmlns"), std::wregex(L"([^:]+):(.*)"))) ns[toBytes(o.valueMatch[1])] = toBytes(o.valueMatch[2]); |
|
68 } |
|
69 |
|
70 bool xinclude = false; |
|
71 |
|
72 void findXIncludeOptions() { |
|
73 for (Option o : getOptions(L"xinclude")) xinclude = o.value == L"true"; |
66 } |
74 } |
67 |
75 |
68 std::wstring rawXmlNodeListWrapperName; |
76 std::wstring rawXmlNodeListWrapperName; |
69 std::wstring rawXmlNodeListWrapperUri; |
77 std::wstring rawXmlNodeListWrapperUri; |
70 std::wstring rawXmlNodeListWrapperPrefix; |
78 std::wstring rawXmlNodeListWrapperPrefix; |
161 |
169 |
162 std::vector<AttributeMetadata> getOutputAttributesMetadata() override { |
170 std::vector<AttributeMetadata> getOutputAttributesMetadata() override { |
163 findXmlnsInEnvironment(); |
171 findXmlnsInEnvironment(); |
164 findXmlnsInOptions(); |
172 findXmlnsInOptions(); |
165 findRawXmlOptions(); |
173 findRawXmlOptions(); |
|
174 findXIncludeOptions(); |
166 |
175 |
167 std::vector<AttributeMetadata> oam; |
176 std::vector<AttributeMetadata> oam; |
168 |
177 |
169 std::vector<Option> modeOptions = getOptions(L"mode"); |
178 std::vector<Option> modeOptions = getOptions(L"mode"); |
170 std::vector<Option> attributeOptions = getOptions(L"attribute"); |
179 std::vector<Option> attributeOptions = getOptions(L"attribute"); |
182 std::vector<OutputAttribute> oa; |
191 std::vector<OutputAttribute> oa; |
183 |
192 |
184 try { |
193 try { |
185 xmlpp::DomParser parser; |
194 xmlpp::DomParser parser; |
186 parser.parse_file(toBytes(getCurrentFile())); |
195 parser.parse_file(toBytes(getCurrentFile())); |
|
196 if (xinclude) parser.get_document()->process_xinclude(true); |
187 xmlpp::Element* root = parser.get_document()->get_root_node(); |
197 xmlpp::Element* root = parser.get_document()->get_root_node(); |
188 |
198 |
189 for (XPathAttribute xpathAttribute : xpathAttributes) { |
199 for (XPathAttribute xpathAttribute : xpathAttributes) { |
190 std::string xpath = toBytes(xpathAttribute.xpath); |
200 std::string xpath = toBytes(xpathAttribute.xpath); |
191 std::wstring result; |
201 std::wstring result; |