equal
deleted
inserted
replaced
50 std::vector<relpipe::writer::AttributeMetadata> currentWriterMetadata; |
50 std::vector<relpipe::writer::AttributeMetadata> currentWriterMetadata; |
51 size_t currentAttributeIndex = 0; |
51 size_t currentAttributeIndex = 0; |
52 size_t currentRecordNumber = 1; |
52 size_t currentRecordNumber = 1; |
53 |
53 |
54 |
54 |
|
55 xmlpp::Node::PrefixNsMap xmlns; |
55 xmlpp::DomParser dom; |
56 xmlpp::DomParser dom; |
56 xmlpp::Element* recordElement = nullptr; |
57 xmlpp::Element* recordElement = nullptr; |
57 relpipe::in::xmltable::XMLNameCodec xmlNameCodec; // TODO: move to a common library |
58 relpipe::in::xmltable::XMLNameCodec xmlNameCodec; // TODO: move to a common library |
58 |
59 |
59 void copyInputAttributesToOutput() { |
60 void copyInputAttributesToOutput() { |
91 } |
92 } |
92 } |
93 } |
93 |
94 |
94 void writeOutputAttributes() { |
95 void writeOutputAttributes() { |
95 for (auto oa : currentRelationConfiguration->outputAttributes) { |
96 for (auto oa : currentRelationConfiguration->outputAttributes) { |
96 auto value = recordElement->eval_to_string(s2x(oa.xpath)); |
97 auto value = recordElement->eval_to_string(s2x(oa.xpath), xmlns); |
97 relationalWriter->writeAttribute(x2s(value)); |
98 relationalWriter->writeAttribute(x2s(value)); |
98 } |
99 } |
99 } |
100 } |
100 |
101 |
101 public: |
102 public: |
102 |
103 |
103 XPathHandler(shared_ptr<relpipe::writer::RelationalWriter> relationalWriter, Configuration configuration) : relationalWriter(relationalWriter), configuration(configuration) { |
104 XPathHandler(shared_ptr<relpipe::writer::RelationalWriter> relationalWriter, Configuration configuration) : relationalWriter(relationalWriter), configuration(configuration) { |
|
105 for (int i = 0; i < configuration.namespaceMappings.size(); i++) { |
|
106 std::string prefix = convertor.to_bytes(configuration.namespaceMappings[i]); |
|
107 std::string uri = convertor.to_bytes(configuration.namespaceMappings[++i]); |
|
108 xmlns[prefix] = uri; |
|
109 } |
104 } |
110 } |
105 |
111 |
106 virtual ~XPathHandler() { |
112 virtual ~XPathHandler() { |
107 } |
113 } |
108 |
114 |
150 } |
156 } |
151 |
157 |
152 currentAttributeIndex++; |
158 currentAttributeIndex++; |
153 |
159 |
154 if (currentAttributeIndex == currentReaderMetadata.size()) { |
160 if (currentAttributeIndex == currentReaderMetadata.size()) { |
155 if (currentRelationConfiguration->where.empty() || recordElement->eval_to_boolean(s2x(currentRelationConfiguration->where))) { |
161 if (currentRelationConfiguration->where.empty() || recordElement->eval_to_boolean(s2x(currentRelationConfiguration->where), xmlns)) { |
156 if (isPrependingInputAttributes()) writeInputAttributes(); |
162 if (isPrependingInputAttributes()) writeInputAttributes(); |
157 writeOutputAttributes(); |
163 writeOutputAttributes(); |
158 if (isAppendingInputAttributes()) writeInputAttributes(); |
164 if (isAppendingInputAttributes()) writeInputAttributes(); |
159 } |
165 } |
160 |
166 |