56 void startRelation(string_t name, std::vector<handlers::AttributeMetadata> attributes) override { |
56 void startRelation(string_t name, std::vector<handlers::AttributeMetadata> attributes) override { |
57 valueCount = 0; |
57 valueCount = 0; |
58 columnCount = 0; |
58 columnCount = 0; |
59 |
59 |
60 if (relationCount == 0) { |
60 if (relationCount == 0) { |
61 xmlWriter->writeStartElement(L"pipe",{L"xmlns", L"tag:globalcode.info,2018:relpipe"}); |
61 xmlWriter->writeStartElement(L"relpipe",{L"xmlns", L"tag:globalcode.info,2018:relpipe"}); |
62 } else { |
62 } else { |
63 xmlWriter->writeEndElement(); |
63 xmlWriter->writeEndElement(); |
64 xmlWriter->writeEndElement(); |
64 xmlWriter->writeEndElement(); |
65 } |
65 } |
66 relationCount++; |
66 relationCount++; |
67 xmlWriter->writeStartElement(L"relation"); |
67 xmlWriter->writeStartElement(L"relation"); |
68 |
68 |
69 xmlWriter->writeTextElement(L"name",{}, name); |
69 xmlWriter->writeTextElement(L"name",{}, name); |
70 |
70 |
71 |
71 |
|
72 xmlWriter->writeStartElement(L"attributes-metadata"); |
72 columnCount = attributes.size(); |
73 columnCount = attributes.size(); |
73 columnTypes.resize(columnCount); |
74 columnTypes.resize(columnCount); |
74 columnTypeCodes.resize(columnCount); |
75 columnTypeCodes.resize(columnCount); |
75 columnNames.resize(columnCount); |
76 columnNames.resize(columnCount); |
76 for (int i = 0; i < attributes.size(); i++) { |
77 for (int i = 0; i < attributes.size(); i++) { |
77 columnNames[i] = attributes[i].getAttributeName(); |
78 columnNames[i] = attributes[i].getAttributeName(); |
78 columnTypes[i] = attributes[i].getTypeId(); |
79 columnTypes[i] = attributes[i].getTypeId(); |
79 columnTypeCodes[i] = attributes[i].getTypeName(); |
80 columnTypeCodes[i] = attributes[i].getTypeName(); |
|
81 xmlWriter->writeEmptyElement(L"attribute-metadata",{ |
|
82 L"name", columnNames[i], |
|
83 L"type", columnTypeCodes[i] |
|
84 }); |
80 } |
85 } |
|
86 xmlWriter->writeEndElement(); |
81 |
87 |
82 // TODO: print attribute metadata |
88 // TODO: print attribute metadata |
83 } |
89 } |
84 |
90 |
85 void attribute(const string_t& value) override { |
91 void attribute(const string_t& value) override { |
88 if (i == 0 && valueCount) xmlWriter->writeEndElement(); |
94 if (i == 0 && valueCount) xmlWriter->writeEndElement(); |
89 if (i == 0) xmlWriter->writeStartElement(L"record"); |
95 if (i == 0) xmlWriter->writeStartElement(L"record"); |
90 |
96 |
91 valueCount++; |
97 valueCount++; |
92 |
98 |
93 // TODO: print attribute metadata (optional) |
99 // TODO: print attribute metadata (only optional, not default) |
94 xmlWriter->writeTextElement(L"attribute",{}, value); |
100 xmlWriter->writeTextElement(L"attribute",{ |
|
101 L"name", columnNames[i], |
|
102 L"type", columnTypeCodes[i] |
|
103 }, value); |
95 |
104 |
96 } |
105 } |
97 |
106 |
98 void endOfPipe() { |
107 void endOfPipe() { |
99 if (valueCount) xmlWriter->writeEndElement(); |
108 if (valueCount) xmlWriter->writeEndElement(); |