# HG changeset patch # User František Kučera # Date 1622300401 -7200 # Node ID 1164d5bc564056069c61c7ce2f343424a5317529 # Parent bdb7ef1ad596969ab116e8696a2cda5880d2ca14 properly close elements when the relation is empty diff -r bdb7ef1ad596 -r 1164d5bc5640 src/XmlHandler.h --- a/src/XmlHandler.h Sat Oct 24 00:08:19 2020 +0200 +++ b/src/XmlHandler.h Sat May 29 17:00:01 2021 +0200 @@ -54,16 +54,17 @@ } void startRelation(string_t name, std::vector attributes) override { - valueCount = 0; - columnCount = 0; - if (relationCount == 0) { xmlWriter->writeStartElement(L"relpipe",{L"xmlns", XMLNS}); } else { - xmlWriter->writeEndElement(); + if (valueCount) xmlWriter->writeEndElement(); xmlWriter->writeEndElement(); } + + valueCount = 0; + columnCount = 0; relationCount++; + xmlWriter->writeStartElement(L"relation"); xmlWriter->writeTextElement(L"name",{}, name); @@ -91,6 +92,7 @@ void attribute(const string_t& value) override { integer_t i = valueCount % columnCount; + // TODO: end element on last attribute instead of first + on end of pipe if (i == 0 && valueCount) xmlWriter->writeEndElement(); if (i == 0) xmlWriter->writeStartElement(L"record");