|
1 /** |
|
2 * Relational pipes |
|
3 * Copyright © 2019 František Kučera (Frantovo.cz, GlobalCode.info) |
|
4 * |
|
5 * This program is free software: you can redistribute it and/or modify |
|
6 * it under the terms of the GNU General Public License as published by |
|
7 * the Free Software Foundation, either version 3 of the License, or |
|
8 * (at your option) any later version. |
|
9 * |
|
10 * This program is distributed in the hope that it will be useful, |
|
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 * GNU General Public License for more details. |
|
14 * |
|
15 * You should have received a copy of the GNU General Public License |
|
16 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
17 */ |
|
18 #pragma once |
|
19 |
|
20 #include <cstdlib> |
|
21 #include <iostream> |
|
22 #include <string> |
|
23 #include <sstream> |
|
24 #include <vector> |
|
25 #include <algorithm> |
|
26 |
|
27 #include <libxml++-2.6/libxml++/libxml++.h> |
|
28 |
|
29 #include <relpipe/writer/typedefs.h> |
|
30 |
|
31 |
|
32 namespace relpipe { |
|
33 namespace in { |
|
34 namespace xmltable { |
|
35 |
|
36 using namespace relpipe::writer; |
|
37 |
|
38 class XMLCommand { |
|
39 private: |
|
40 |
|
41 public: |
|
42 |
|
43 void process(std::istream& input, std::ostream& output) { |
|
44 |
|
45 |
|
46 xmlpp::DomParser parser; |
|
47 parser.parse_stream(input); |
|
48 xmlpp::Document* d = parser.get_document(); |
|
49 xmlpp::Element* r = d->get_root_node(); |
|
50 |
|
51 xmlpp::Node::PrefixNsMap m; |
|
52 m["rp"] = "tag:globalcode.info,2018:relpipe"; |
|
53 |
|
54 output << "root: " << r->get_name() << std::endl; |
|
55 |
|
56 for (xmlpp::Node* n : r->find("//rp:attribute", m)) { |
|
57 |
|
58 output << "node:" << n->get_name() << std::endl; |
|
59 |
|
60 } |
|
61 |
|
62 |
|
63 } |
|
64 }; |
|
65 |
|
66 } |
|
67 } |
|
68 } |