equal
deleted
inserted
replaced
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::Node::PrefixNsMap xmlns; |
56 xmlpp::DomParser dom; |
56 xmlpp::Document dom; |
57 xmlpp::Element* recordElement = nullptr; |
57 xmlpp::Element* recordElement = nullptr; |
58 relpipe::in::xmltable::XMLNameCodec xmlNameCodec; // TODO: move to a common library |
58 relpipe::in::xmltable::XMLNameCodec xmlNameCodec; // TODO: move to a common library |
59 |
59 |
60 void copyInputAttributesToOutput() { |
60 void copyInputAttributesToOutput() { |
61 for (auto rm : currentReaderMetadata) currentWriterMetadata.push_back({rm.getAttributeName(), relationalWriter->toTypeId(rm.getTypeName())}); |
61 for (auto rm : currentReaderMetadata) currentWriterMetadata.push_back({rm.getAttributeName(), relationalWriter->toTypeId(rm.getTypeName())}); |
69 bool isAppendingInputAttributes() { |
69 bool isAppendingInputAttributes() { |
70 return currentRelationConfiguration->inputAttributePolicy == InputAttributePolicy::Append; |
70 return currentRelationConfiguration->inputAttributePolicy == InputAttributePolicy::Append; |
71 } |
71 } |
72 |
72 |
73 void resetRecordElement() { |
73 void resetRecordElement() { |
74 if (recordElement) dom.get_document()->get_root_node()->remove_child(recordElement); |
74 if (recordElement) dom.get_root_node()->remove_child(recordElement); |
75 recordElement = dom.get_document()->get_root_node()->add_child("record"); |
75 recordElement = dom.get_root_node()->add_child("record"); |
76 } |
76 } |
77 |
77 |
78 const Glib::ustring s2x(relpipe::common::type::StringX value) { |
78 const Glib::ustring s2x(relpipe::common::type::StringX value) { |
79 return Glib::ustring(convertor.to_bytes(value)); |
79 return Glib::ustring(convertor.to_bytes(value)); |
80 } |
80 } |
132 } else { |
132 } else { |
133 if (isPrependingInputAttributes()) copyInputAttributesToOutput(); |
133 if (isPrependingInputAttributes()) copyInputAttributesToOutput(); |
134 for (auto oa : currentRelationConfiguration->outputAttributes) currentWriterMetadata.push_back({oa.name, oa.type}); |
134 for (auto oa : currentRelationConfiguration->outputAttributes) currentWriterMetadata.push_back({oa.name, oa.type}); |
135 if (isAppendingInputAttributes()) copyInputAttributesToOutput(); |
135 if (isAppendingInputAttributes()) copyInputAttributesToOutput(); |
136 |
136 |
137 dom.get_document()->create_root_node("relpipe-tr-xpath"); |
137 dom.create_root_node("relpipe-tr-xpath"); |
138 dom.get_document()->get_root_node()->add_child("relation-name")->add_child_text(s2x(name)); |
138 dom.get_root_node()->add_child("relation-name")->add_child_text(s2x(name)); |
139 resetRecordElement(); |
139 resetRecordElement(); |
140 } |
140 } |
141 |
141 |
142 relationalWriter->startRelation(name, currentWriterMetadata, true); |
142 relationalWriter->startRelation(name, currentWriterMetadata, true); |
143 } |
143 } |