Avoid extra newlines in XML mapping in table forest mode
authorPeter Eisentraut
Thu, 12 Jul 2012 20:47:33 +0000 (23:47 +0300)
committerPeter Eisentraut
Thu, 12 Jul 2012 20:52:50 +0000 (23:52 +0300)
found by P. Broennimann

src/backend/utils/adt/xml.c
src/test/regress/expected/xmlmap.out

index 44d327d7606df620c01b6e6532e53a9ee7a21f23..a9150e856921c33496a036a9fa8a0c622f47178d 100644 (file)
@@ -2383,7 +2383,7 @@ xmldata_root_element_start(StringInfo result, const char *eltname,
        else
            appendStringInfo(result, " xsi:noNamespaceSchemaLocation=\"#\"");
    }
-   appendStringInfo(result, ">\n\n");
+   appendStringInfo(result, ">\n");
 }
 
 
@@ -2417,8 +2417,11 @@ query_to_xml_internal(const char *query, char *tablename,
                 errmsg("invalid query")));
 
    if (!tableforest)
+   {
        xmldata_root_element_start(result, xmltn, xmlschema,
                                   targetns, top_level);
+       appendStringInfoString(result, "\n");
+   }
 
    if (xmlschema)
        appendStringInfo(result, "%s\n\n", xmlschema);
@@ -2581,6 +2584,7 @@ schema_to_xml_internal(Oid nspid, const char *xmlschema, bool nulls,
    result = makeStringInfo();
 
    xmldata_root_element_start(result, xmlsn, xmlschema, targetns, top_level);
+   appendStringInfoString(result, "\n");
 
    if (xmlschema)
        appendStringInfo(result, "%s\n\n", xmlschema);
@@ -2758,6 +2762,7 @@ database_to_xml_internal(const char *xmlschema, bool nulls,
    result = makeStringInfo();
 
    xmldata_root_element_start(result, xmlcn, xmlschema, targetns, true);
+   appendStringInfoString(result, "\n");
 
    if (xmlschema)
        appendStringInfo(result, "%s\n\n", xmlschema);
index cf46c9ffb58291d63074d75acd53b40872ccb00f..d54410b2310968127143840e5445b39e7e4a8a2a 100644 (file)
@@ -56,19 +56,16 @@ SELECT table_to_xml('testxmlschema.test1', false, true, '');
                          table_to_xml                          
 ---------------------------------------------------------------
  +
-                                                              +
    1                                                   +
    one                                                 +
                                                       +
                                                               +
  +
-                                                              +
    2                                                   +
    two                                                 +
                                                       +
                                                               +
  +
-                                                              +
    -1                                                  +
                                                       +
                                                               +
@@ -79,19 +76,16 @@ SELECT table_to_xml('testxmlschema.test1', true, true, '');
                          table_to_xml                          
 ---------------------------------------------------------------
  +
-                                                              +
    1                                                   +
    one                                                 +
                                                       +
                                                               +
  +
-                                                              +
    2                                                   +
    two                                                 +
                                                       +
                                                               +
  +
-                                                              +
    -1                                                  +
                                            +
                                                       +
@@ -510,19 +504,16 @@ SELECT table_to_xml_and_xmlschema('testxmlschema.test1', false, true, '');
                                                                                 +
                                                                                              +
                                 +
-                                                                                             +
    1                                                                                  +
    one                                                                                +
                                                                                      +
                                                                                              +
                                 +
-                                                                                             +
    2                                                                                  +
    two                                                                                +
                                                                                      +
                                                                                              +
                                 +
-                                                                                             +
    -1                                                                                 +
                                                                                      +
                                                                                              +
@@ -561,19 +552,16 @@ SELECT table_to_xml_and_xmlschema('testxmlschema.test1', true, true, 'foo');
                                                                                   +
                                                                                                +
                       +
-                                                                                               +
    1                                                                                    +
    one                                                                                  +
                                                                                        +
                                                                                                +
                       +
-                                                                                               +
    2                                                                                    +
    two                                                                                  +
                                                                                        +
                                                                                                +
                       +
-                                                                                               +
    -1                                                                                   +
                                                                             +
                                                                                        +
@@ -670,19 +658,16 @@ SELECT query_to_xml_and_xmlschema('SELECT * FROM testxmlschema.test1', true, tru
                                                                                   +
                                                                                                +
                                     +
-                                                                                               +
    1                                                                                    +
    one                                                                                  +
                                                                                          +
                                                                                                +
                                     +
-                                                                                               +
    2                                                                                    +
    two                                                                                  +
                                                                                          +
                                                                                                +
                                     +
-                                                                                               +
    -1                                                                                   +
                                                                             +
                                                                                          +
@@ -695,18 +680,15 @@ SELECT cursor_to_xml('xc'::refcursor, 5, false, true, '');
                         cursor_to_xml                        
 -------------------------------------------------------------
  +
-                                                            +
    -1                                                +
                                                       +
                                                             +
  +
-                                                            +
    1                                                 +
    one                                               +
                                                       +
                                                             +
  +
-                                                            +
    2                                                 +
    two                                               +
                                                       +
@@ -773,25 +755,21 @@ SELECT schema_to_xml('testxmlschema', false, true, '');
  +
                                                                       +
                                                                +
-                                                                      +
    1                                                           +
    one                                                         +
                                                               +
                                                                       +
                                                                +
-                                                                      +
    2                                                           +
    two                                                         +
                                                               +
                                                                       +
                                                                +
-                                                                      +
    -1                                                          +
                                                               +
                                                                       +
                                                                       +
                                                                +
-                                                                      +
    55                                                          +
    abc                                                         +
    def                                                         +
@@ -1159,26 +1137,22 @@ SELECT schema_to_xml_and_xmlschema('testxmlschema', true, true, 'foo');
                                                                                                      +
                                                                                                                   +
                                                                                                            +
-                                                                                                                  +
    1                                                                                                       +
    one                                                                                                     +
                                                                                                           +
                                                                                                                   +
                                                                                                            +
-                                                                                                                  +
    2                                                                                                       +
    two                                                                                                     +
                                                                                                           +
                                                                                                                   +
                                                                                                            +
-                                                                                                                  +
    -1                                                                                                      +
                                                                                                +
                                                                                                           +
                                                                                                                   +
                                                                                                                   +
                                                                                                            +
-                                                                                                                  +
    55                                                                                                      +
    abc                                                                                                     +
    def                                                                                                     +