Commit a84bf492 authored by Peter Eisentraut's avatar Peter Eisentraut

Avoid extra newlines in XML mapping in table forest mode

found by P. Broennimann
parent a36088bc
...@@ -2383,7 +2383,7 @@ xmldata_root_element_start(StringInfo result, const char *eltname, ...@@ -2383,7 +2383,7 @@ xmldata_root_element_start(StringInfo result, const char *eltname,
else else
appendStringInfo(result, " xsi:noNamespaceSchemaLocation=\"#\""); appendStringInfo(result, " xsi:noNamespaceSchemaLocation=\"#\"");
} }
appendStringInfo(result, ">\n\n"); appendStringInfo(result, ">\n");
} }
...@@ -2417,8 +2417,11 @@ query_to_xml_internal(const char *query, char *tablename, ...@@ -2417,8 +2417,11 @@ query_to_xml_internal(const char *query, char *tablename,
errmsg("invalid query"))); errmsg("invalid query")));
if (!tableforest) if (!tableforest)
{
xmldata_root_element_start(result, xmltn, xmlschema, xmldata_root_element_start(result, xmltn, xmlschema,
targetns, top_level); targetns, top_level);
appendStringInfoString(result, "\n");
}
if (xmlschema) if (xmlschema)
appendStringInfo(result, "%s\n\n", xmlschema); appendStringInfo(result, "%s\n\n", xmlschema);
...@@ -2581,6 +2584,7 @@ schema_to_xml_internal(Oid nspid, const char *xmlschema, bool nulls, ...@@ -2581,6 +2584,7 @@ schema_to_xml_internal(Oid nspid, const char *xmlschema, bool nulls,
result = makeStringInfo(); result = makeStringInfo();
xmldata_root_element_start(result, xmlsn, xmlschema, targetns, top_level); xmldata_root_element_start(result, xmlsn, xmlschema, targetns, top_level);
appendStringInfoString(result, "\n");
if (xmlschema) if (xmlschema)
appendStringInfo(result, "%s\n\n", xmlschema); appendStringInfo(result, "%s\n\n", xmlschema);
...@@ -2758,6 +2762,7 @@ database_to_xml_internal(const char *xmlschema, bool nulls, ...@@ -2758,6 +2762,7 @@ database_to_xml_internal(const char *xmlschema, bool nulls,
result = makeStringInfo(); result = makeStringInfo();
xmldata_root_element_start(result, xmlcn, xmlschema, targetns, true); xmldata_root_element_start(result, xmlcn, xmlschema, targetns, true);
appendStringInfoString(result, "\n");
if (xmlschema) if (xmlschema)
appendStringInfo(result, "%s\n\n", xmlschema); appendStringInfo(result, "%s\n\n", xmlschema);
......
...@@ -56,19 +56,16 @@ SELECT table_to_xml('testxmlschema.test1', false, true, ''); ...@@ -56,19 +56,16 @@ SELECT table_to_xml('testxmlschema.test1', false, true, '');
table_to_xml table_to_xml
--------------------------------------------------------------- ---------------------------------------------------------------
<test1 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">+ <test1 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">+
+
<a>1</a> + <a>1</a> +
<b>one</b> + <b>one</b> +
</test1> + </test1> +
+ +
<test1 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">+ <test1 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">+
+
<a>2</a> + <a>2</a> +
<b>two</b> + <b>two</b> +
</test1> + </test1> +
+ +
<test1 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">+ <test1 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">+
+
<a>-1</a> + <a>-1</a> +
</test1> + </test1> +
+ +
...@@ -79,19 +76,16 @@ SELECT table_to_xml('testxmlschema.test1', true, true, ''); ...@@ -79,19 +76,16 @@ SELECT table_to_xml('testxmlschema.test1', true, true, '');
table_to_xml table_to_xml
--------------------------------------------------------------- ---------------------------------------------------------------
<test1 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">+ <test1 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">+
+
<a>1</a> + <a>1</a> +
<b>one</b> + <b>one</b> +
</test1> + </test1> +
+ +
<test1 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">+ <test1 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">+
+
<a>2</a> + <a>2</a> +
<b>two</b> + <b>two</b> +
</test1> + </test1> +
+ +
<test1 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">+ <test1 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">+
+
<a>-1</a> + <a>-1</a> +
<b xsi:nil="true"/> + <b xsi:nil="true"/> +
</test1> + </test1> +
...@@ -510,19 +504,16 @@ SELECT table_to_xml_and_xmlschema('testxmlschema.test1', false, true, ''); ...@@ -510,19 +504,16 @@ SELECT table_to_xml_and_xmlschema('testxmlschema.test1', false, true, '');
</xsd:schema> + </xsd:schema> +
+ +
<test1 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <test1 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> +
+
<a>1</a> + <a>1</a> +
<b>one</b> + <b>one</b> +
</test1> + </test1> +
+ +
<test1 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <test1 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> +
+
<a>2</a> + <a>2</a> +
<b>two</b> + <b>two</b> +
</test1> + </test1> +
+ +
<test1 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <test1 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> +
+
<a>-1</a> + <a>-1</a> +
</test1> + </test1> +
+ +
...@@ -561,19 +552,16 @@ SELECT table_to_xml_and_xmlschema('testxmlschema.test1', true, true, 'foo'); ...@@ -561,19 +552,16 @@ SELECT table_to_xml_and_xmlschema('testxmlschema.test1', true, true, 'foo');
</xsd:schema> + </xsd:schema> +
+ +
<test1 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="foo"> + <test1 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="foo"> +
+
<a>1</a> + <a>1</a> +
<b>one</b> + <b>one</b> +
</test1> + </test1> +
+ +
<test1 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="foo"> + <test1 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="foo"> +
+
<a>2</a> + <a>2</a> +
<b>two</b> + <b>two</b> +
</test1> + </test1> +
+ +
<test1 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="foo"> + <test1 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="foo"> +
+
<a>-1</a> + <a>-1</a> +
<b xsi:nil="true"/> + <b xsi:nil="true"/> +
</test1> + </test1> +
...@@ -670,19 +658,16 @@ SELECT query_to_xml_and_xmlschema('SELECT * FROM testxmlschema.test1', true, tru ...@@ -670,19 +658,16 @@ SELECT query_to_xml_and_xmlschema('SELECT * FROM testxmlschema.test1', true, tru
</xsd:schema> + </xsd:schema> +
+ +
<row xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <row xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> +
+
<a>1</a> + <a>1</a> +
<b>one</b> + <b>one</b> +
</row> + </row> +
+ +
<row xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <row xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> +
+
<a>2</a> + <a>2</a> +
<b>two</b> + <b>two</b> +
</row> + </row> +
+ +
<row xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <row xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> +
+
<a>-1</a> + <a>-1</a> +
<b xsi:nil="true"/> + <b xsi:nil="true"/> +
</row> + </row> +
...@@ -695,18 +680,15 @@ SELECT cursor_to_xml('xc'::refcursor, 5, false, true, ''); ...@@ -695,18 +680,15 @@ SELECT cursor_to_xml('xc'::refcursor, 5, false, true, '');
cursor_to_xml cursor_to_xml
------------------------------------------------------------- -------------------------------------------------------------
<row xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">+ <row xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">+
+
<a>-1</a> + <a>-1</a> +
</row> + </row> +
+ +
<row xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">+ <row xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">+
+
<a>1</a> + <a>1</a> +
<b>one</b> + <b>one</b> +
</row> + </row> +
+ +
<row xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">+ <row xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">+
+
<a>2</a> + <a>2</a> +
<b>two</b> + <b>two</b> +
</row> + </row> +
...@@ -773,25 +755,21 @@ SELECT schema_to_xml('testxmlschema', false, true, ''); ...@@ -773,25 +755,21 @@ SELECT schema_to_xml('testxmlschema', false, true, '');
<testxmlschema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">+ <testxmlschema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">+
+ +
<test1> + <test1> +
+
<a>1</a> + <a>1</a> +
<b>one</b> + <b>one</b> +
</test1> + </test1> +
+ +
<test1> + <test1> +
+
<a>2</a> + <a>2</a> +
<b>two</b> + <b>two</b> +
</test1> + </test1> +
+ +
<test1> + <test1> +
+
<a>-1</a> + <a>-1</a> +
</test1> + </test1> +
+ +
+ +
<test2> + <test2> +
+
<z>55</z> + <z>55</z> +
<y>abc</y> + <y>abc</y> +
<x>def </x> + <x>def </x> +
...@@ -1159,26 +1137,22 @@ SELECT schema_to_xml_and_xmlschema('testxmlschema', true, true, 'foo'); ...@@ -1159,26 +1137,22 @@ SELECT schema_to_xml_and_xmlschema('testxmlschema', true, true, 'foo');
</xsd:schema> + </xsd:schema> +
+ +
<test1> + <test1> +
+
<a>1</a> + <a>1</a> +
<b>one</b> + <b>one</b> +
</test1> + </test1> +
+ +
<test1> + <test1> +
+
<a>2</a> + <a>2</a> +
<b>two</b> + <b>two</b> +
</test1> + </test1> +
+ +
<test1> + <test1> +
+
<a>-1</a> + <a>-1</a> +
<b xsi:nil="true"/> + <b xsi:nil="true"/> +
</test1> + </test1> +
+ +
+ +
<test2> + <test2> +
+
<z>55</z> + <z>55</z> +
<y>abc</y> + <y>abc</y> +
<x>def </x> + <x>def </x> +
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment