--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/streamlet-examples/xpath.cpp Mon Jan 27 00:29:56 2020 +0100
@@ -0,0 +1,46 @@
+/**
+ * Relational pipes
+ * Copyright © 2020 František Kučera (Frantovo.cz, GlobalCode.info)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, version 3 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "streamlet-common.h"
+
+#include <libxml++-2.6/libxml++/libxml++.h>
+
+class XPathStreamlet : public Streamlet {
+
+ std::vector<AttributeMetadata> getOutputAttributesMetadata() override {
+ std::vector<AttributeMetadata> oam;
+ oam.push_back({getAlias(0, L"xpath"), L"string"});
+ return oam;
+ }
+
+ std::vector<OutputAttribute> getOutputAttributes() override {
+ std::vector<OutputAttribute> oa;
+
+ try {
+ xmlpp::DomParser parser;
+ parser.parse_file(convertor.to_bytes(currentFile));
+ xmlpp::Element* root = parser.get_document()->get_root_node();
+ oa.push_back({L"XML OK", false});
+ } catch (...) {
+ oa.push_back({L"invalid XML", true});
+ }
+
+ return oa;
+ }
+};
+
+STREAMLET_RUN(XPathStreamlet)