Обсуждение: BUG #3734: Invalid XML schema output.

Поиск
Список
Период
Сортировка

BUG #3734: Invalid XML schema output.

От
"Ben Leslie"
Дата:
The following bug has been logged online:

Bug reference:      3734
Logged by:          Ben Leslie
Email address:      benno@benno.id.au
PostgreSQL version: 8.3 beta2
Operating system:   Mac OS X
Description:        Invalid XML schema output.
Details:

database_to_xml_and_xmlschema creates an invalid XML in certain
circumstances.

To recreate:

CREATE DATABASE test;
\c test
CREATE DOMAIN isoweek AS date CHECK (date_trunc('week', VALUE) = VALUE);
CREATE TABLE test (x isoweek);
INSERT INTO test VALUES ('2007-01-01');

Now to see the bug:

SELECT database_to_xml_and_xmlschema('t', 'f', '');

The output is:

 <test xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="#">

 <xsd:schema
     xmlns:xsd="http://www.w3.org/2001/XMLSchema">

 <xsd:simpleType name="Domain.test.public.isoweek">
   <xsd:restriction base="DATE">
 </xsd:simpleType>

 <xsd:simpleType name="DATE">
   <xsd:restriction base="xsd:date">
     <xsd:pattern value="\p{Nd}{4}-\p{Nd}{2}-\p{Nd}{2}"/>
   </xsd:restriction>
 </xsd:simpleType>

 <xsd:complexType name="CatalogType.test">
   <xsd:all>
     <xsd:element name="public" type="SchemaType.test.public" />
   </xsd:all>
 </xsd:complexType>

 <xsd:element name="test" type="CatalogType.test"/>

 </xsd:schema>

 <public>

 <test>

 <row>
   <x>2007-01-01</x>
 </row>

 </test>

 </public>

 </test>


The specific problem is that the following is malformed; the xsd:restriction
tag is never closed.

 <xsd:simpleType name="Domain.test.public.isoweek">
   <xsd:restriction base="DATE">
 </xsd:simpleType>

The correct output (as far as I can tell) should be:

 <xsd:simpleType name="Domain.test.public.isoweek">
   <xsd:restriction base="DATE" />
 </xsd:simpleType>

Re: BUG #3734: Invalid XML schema output.

От
Euler Taveira de Oliveira
Дата:
Ben Leslie wrote:

> The specific problem is that the following is malformed; the xsd:restriction
> tag is never closed.
>
>  <xsd:simpleType name="Domain.test.public.isoweek">
>    <xsd:restriction base="DATE">
>  </xsd:simpleType>
>
Exact. Per 9.11 (6, b, iv) or 9.15 (8, m, vi), it's a simple element.
The attached patch should fix it.
I'm attaching another small patch to strip some space and be consistent
with other xml tags.


--
  Euler Taveira de Oliveira
  http://www.timbira.com/
*** src/backend/utils/adt/xml.c.orig    2007-11-09 16:33:56.000000000 -0200
--- src/backend/utils/adt/xml.c    2007-11-09 16:37:30.000000000 -0200
***************
*** 2987,2993 ****
                      base_typeoid = getBaseTypeAndTypmod(typeoid, &base_typmod);

                      appendStringInfo(&result,
!                                      "  <xsd:restriction base=\"%s\">\n",
                                       map_sql_type_to_xml_name(base_typeoid, base_typmod));
                  }
          }
--- 2987,2993 ----
                      base_typeoid = getBaseTypeAndTypmod(typeoid, &base_typmod);

                      appendStringInfo(&result,
!                                      "  <xsd:restriction base=\"%s\"/>\n",
                                       map_sql_type_to_xml_name(base_typeoid, base_typmod));
                  }
          }
*** src/backend/utils/adt/xml.c.orig    2007-11-09 16:33:56.000000000 -0200
--- src/backend/utils/adt/xml.c    2007-11-09 17:01:50.000000000 -0200
***************
*** 2595,2605 ****

          if (!tableforest)
              appendStringInfo(&result,
!                              "    <xsd:element name=\"%s\" type=\"%s\" />\n",
                               xmltn, tabletypename);
          else
              appendStringInfo(&result,
!                              "    <xsd:element name=\"%s\" type=\"%s\" minOccurs=\"0\" maxOccurs=\"unbounded\" />\n",
                               xmltn, tabletypename);
      }

--- 2595,2605 ----

          if (!tableforest)
              appendStringInfo(&result,
!                              "    <xsd:element name=\"%s\" type=\"%s\"/>\n",
                               xmltn, tabletypename);
          else
              appendStringInfo(&result,
!                              "    <xsd:element name=\"%s\" type=\"%s\" minOccurs=\"0\" maxOccurs=\"unbounded\"/>\n",
                               xmltn, tabletypename);
      }

***************
*** 2656,2662 ****
                                                                          NULL);

          appendStringInfo(&result,
!                          "    <xsd:element name=\"%s\" type=\"%s\" />\n",
                           xmlsn, schematypename);
      }

--- 2656,2662 ----
                                                                          NULL);

          appendStringInfo(&result,
!                          "    <xsd:element name=\"%s\" type=\"%s\"/>\n",
                           xmlsn, schematypename);
      }

Re: BUG #3734: Invalid XML schema output.

От
Tom Lane
Дата:
Euler Taveira de Oliveira <euler@timbira.com> writes:
> Ben Leslie wrote:
>> The specific problem is that the following is malformed; the xsd:restriction
>> tag is never closed.

> Exact. Per 9.11 (6, b, iv) or 9.15 (8, m, vi), it's a simple element.
> The attached patch should fix it.
> I'm attaching another small patch to strip some space and be consistent
> with other xml tags.

Applied, thanks.

            regards, tom lane

Re: BUG #3734: Invalid XML schema output.

От
Peter Eisentraut
Дата:
Euler Taveira de Oliveira wrote:
> I'm attaching another small patch to strip some space and be
> consistent with other xml tags.

Having a space before /> appears to be common practice, including in the
examples in the SQL/XML spec.

--
Peter Eisentraut
http://developer.postgresql.org/~petere/

Re: BUG #3734: Invalid XML schema output.

От
Euler Taveira de Oliveira
Дата:
Peter Eisentraut wrote:

> Having a space before /> appears to be common practice, including in the
> examples in the SQL/XML spec.
>
Agreed. Feel free to add whitespace before every /> of simple xml elements.

--
  Euler Taveira de Oliveira
  http://www.timbira.com/

Re: BUG #3734: Invalid XML schema output.

От
Bruce Momjian
Дата:
Euler Taveira de Oliveira wrote:
> Peter Eisentraut wrote:
>
> > Having a space before /> appears to be common practice, including in the
> > examples in the SQL/XML spec.
> >
> Agreed. Feel free to add whitespace before every /> of simple xml elements.

Uh, was this done?

--
  Bruce Momjian  <bruce@momjian.us>        http://momjian.us
  EnterpriseDB                             http://postgres.enterprisedb.com

  + If your life is a hard drive, Christ can be your backup. +

Re: BUG #3734: Invalid XML schema output.

От
Peter Eisentraut
Дата:
Bruce Momjian wrote:
> Euler Taveira de Oliveira wrote:
> > Peter Eisentraut wrote:
> > > Having a space before /> appears to be common practice, including in
> > > the examples in the SQL/XML spec.
> >
> > Agreed. Feel free to add whitespace before every /> of simple xml
> > elements.
>
> Uh, was this done?

I didn't want to bother.  It seems alright as it is.

--
Peter Eisentraut
http://developer.postgresql.org/~petere/

Re: BUG #3734: Invalid XML schema output.

От
Bruce Momjian
Дата:
Peter Eisentraut wrote:
> Bruce Momjian wrote:
> > Euler Taveira de Oliveira wrote:
> > > Peter Eisentraut wrote:
> > > > Having a space before /> appears to be common practice, including in
> > > > the examples in the SQL/XML spec.
> > >
> > > Agreed. Feel free to add whitespace before every /> of simple xml
> > > elements.
> >
> > Uh, was this done?
>
> I didn't want to bother.  It seems alright as it is.

OK, I kept the idea for 8.4, just in case.

--
  Bruce Momjian  <bruce@momjian.us>        http://momjian.us
  EnterpriseDB                             http://postgres.enterprisedb.com

  + If your life is a hard drive, Christ can be your backup. +

Re: BUG #3734: Invalid XML schema output.

От
Euler Taveira de Oliveira
Дата:
Bruce Momjian wrote:

>> Agreed. Feel free to add whitespace before every /> of simple xml elements.
>
> Uh, was this done?
>
Nope. Attached is a patch that does it. I'm attaching another cosmetic
patch that replaces the use of some single quotes with double quotes in
the XML attributes output.


--
  Euler Taveira de Oliveira
  http://www.timbira.com/
*** ./src/backend/utils/adt/xml.c.orig    2007-11-23 01:55:00.000000000 -0200
--- ./src/backend/utils/adt/xml.c    2007-11-23 02:01:24.000000000 -0200
***************
*** 2641,2658 ****
          appendStringInfo(&result,
                           "<xsd:complexType name=\"%s\">\n"
                           "  <xsd:sequence>\n"
!                          "    <xsd:element name=\"row\" type=\"%s\" minOccurs=\"0\" maxOccurs=\"unbounded\"/>\n"
                           "  </xsd:sequence>\n"
                           "</xsd:complexType>\n\n",
                           tabletypename, rowtypename);

          appendStringInfo(&result,
!                          "<xsd:element name=\"%s\" type=\"%s\"/>\n\n",
                           xmltn, tabletypename);
      }
      else
          appendStringInfo(&result,
!                          "<xsd:element name=\"%s\" type=\"%s\"/>\n\n",
                           xmltn, rowtypename);

      xsd_schema_element_end(&result);
--- 2641,2658 ----
          appendStringInfo(&result,
                           "<xsd:complexType name=\"%s\">\n"
                           "  <xsd:sequence>\n"
!                          "    <xsd:element name=\"row\" type=\"%s\" minOccurs=\"0\" maxOccurs=\"unbounded\" />\n"
                           "  </xsd:sequence>\n"
                           "</xsd:complexType>\n\n",
                           tabletypename, rowtypename);

          appendStringInfo(&result,
!                          "<xsd:element name=\"%s\" type=\"%s\" />\n\n",
                           xmltn, tabletypename);
      }
      else
          appendStringInfo(&result,
!                          "<xsd:element name=\"%s\" type=\"%s\" />\n\n",
                           xmltn, rowtypename);

      xsd_schema_element_end(&result);
***************
*** 2709,2719 ****

          if (!tableforest)
              appendStringInfo(&result,
!                              "    <xsd:element name=\"%s\" type=\"%s\"/>\n",
                               xmltn, tabletypename);
          else
              appendStringInfo(&result,
!                              "    <xsd:element name=\"%s\" type=\"%s\" minOccurs=\"0\" maxOccurs=\"unbounded\"/>\n",
                               xmltn, tabletypename);
      }

--- 2709,2719 ----

          if (!tableforest)
              appendStringInfo(&result,
!                              "    <xsd:element name=\"%s\" type=\"%s\" />\n",
                               xmltn, tabletypename);
          else
              appendStringInfo(&result,
!                              "    <xsd:element name=\"%s\" type=\"%s\" minOccurs=\"0\" maxOccurs=\"unbounded\" />\n",
                               xmltn, tabletypename);
      }

***************
*** 2727,2733 ****
                             "</xsd:complexType>\n\n");

      appendStringInfo(&result,
!                      "<xsd:element name=\"%s\" type=\"%s\"/>\n\n",
                       xmlsn, schematypename);

      return result.data;
--- 2727,2733 ----
                             "</xsd:complexType>\n\n");

      appendStringInfo(&result,
!                      "<xsd:element name=\"%s\" type=\"%s\" />\n\n",
                       xmlsn, schematypename);

      return result.data;
***************
*** 2775,2781 ****
                                                                         NULL);

          appendStringInfo(&result,
!                          "    <xsd:element name=\"%s\" type=\"%s\"/>\n",
                           xmlsn, schematypename);
      }

--- 2775,2781 ----
                                                                         NULL);

          appendStringInfo(&result,
!                          "    <xsd:element name=\"%s\" type=\"%s\" />\n",
                           xmlsn, schematypename);
      }

***************
*** 2785,2791 ****
                             "</xsd:complexType>\n\n");

      appendStringInfo(&result,
!                      "<xsd:element name=\"%s\" type=\"%s\"/>\n\n",
                       xmlcn, catalogtypename);

      return result.data;
--- 2785,2791 ----
                             "</xsd:complexType>\n\n");

      appendStringInfo(&result,
!                      "<xsd:element name=\"%s\" type=\"%s\" />\n\n",
                       xmlcn, catalogtypename);

      return result.data;
***************
*** 2969,2975 ****
          appendStringInfo(&result,
                           "<xsd:complexType mixed=\"true\">\n"
                           "  <xsd:sequence>\n"
!                          "    <xsd:any name=\"element\" minOccurs=\"0\" maxOccurs=\"unbounded\"
processContents=\"skip\"/>\n"
                           "  </xsd:sequence>\n"
                           "</xsd:complexType>\n");
      }
--- 2969,2975 ----
          appendStringInfo(&result,
                           "<xsd:complexType mixed=\"true\">\n"
                           "  <xsd:sequence>\n"
!                          "    <xsd:any name=\"element\" minOccurs=\"0\" maxOccurs=\"unbounded\"
processContents=\"skip\"/>\n" 
                           "  </xsd:sequence>\n"
                           "</xsd:complexType>\n");
      }
***************
*** 2986,2992 ****
                  if (typmod != -1)
                      appendStringInfo(&result,
                                    "  <xsd:restriction base=\"xsd:string\">\n"
!                                      "    <xsd:maxLength value=\"%d\"/>\n"
                                       "  </xsd:restriction>\n",
                                       typmod - VARHDRSZ);
                  break;
--- 2986,2992 ----
                  if (typmod != -1)
                      appendStringInfo(&result,
                                    "  <xsd:restriction base=\"xsd:string\">\n"
!                                      "    <xsd:maxLength value=\"%d\" />\n"
                                       "  </xsd:restriction>\n",
                                       typmod - VARHDRSZ);
                  break;
***************
*** 3001,3008 ****
                  if (typmod != -1)
                      appendStringInfo(&result,
                                   "  <xsd:restriction base=\"xsd:decimal\">\n"
!                                      "    <xsd:totalDigits value=\"%d\"/>\n"
!                                    "    <xsd:fractionDigits value=\"%d\"/>\n"
                                       "  </xsd:restriction>\n",
                                       ((typmod - VARHDRSZ) >> 16) & 0xffff,
                                       (typmod - VARHDRSZ) & 0xffff);
--- 3001,3008 ----
                  if (typmod != -1)
                      appendStringInfo(&result,
                                   "  <xsd:restriction base=\"xsd:decimal\">\n"
!                                      "    <xsd:totalDigits value=\"%d\" />\n"
!                                    "    <xsd:fractionDigits value=\"%d\" />\n"
                                       "  </xsd:restriction>\n",
                                       ((typmod - VARHDRSZ) >> 16) & 0xffff,
                                       (typmod - VARHDRSZ) & 0xffff);
***************
*** 3011,3018 ****
              case INT2OID:
                  appendStringInfo(&result,
                                   "  <xsd:restriction base=\"xsd:short\">\n"
!                                  "    <xsd:maxInclusive value=\"%d\"/>\n"
!                                  "    <xsd:minInclusive value=\"%d\"/>\n"
                                   "  </xsd:restriction>\n",
                                   SHRT_MAX, SHRT_MIN);
                  break;
--- 3011,3018 ----
              case INT2OID:
                  appendStringInfo(&result,
                                   "  <xsd:restriction base=\"xsd:short\">\n"
!                                  "    <xsd:maxInclusive value=\"%d\" />\n"
!                                  "    <xsd:minInclusive value=\"%d\" />\n"
                                   "  </xsd:restriction>\n",
                                   SHRT_MAX, SHRT_MIN);
                  break;
***************
*** 3020,3027 ****
              case INT4OID:
                  appendStringInfo(&result,
                                   "  <xsd:restriction base='xsd:int'>\n"
!                                  "    <xsd:maxInclusive value=\"%d\"/>\n"
!                                  "    <xsd:minInclusive value=\"%d\"/>\n"
                                   "  </xsd:restriction>\n",
                                   INT_MAX, INT_MIN);
                  break;
--- 3020,3027 ----
              case INT4OID:
                  appendStringInfo(&result,
                                   "  <xsd:restriction base='xsd:int'>\n"
!                                  "    <xsd:maxInclusive value=\"%d\" />\n"
!                                  "    <xsd:minInclusive value=\"%d\" />\n"
                                   "  </xsd:restriction>\n",
                                   INT_MAX, INT_MIN);
                  break;
***************
*** 3029,3036 ****
              case INT8OID:
                  appendStringInfo(&result,
                                   "  <xsd:restriction base=\"xsd:long\">\n"
!                        "    <xsd:maxInclusive value=\"" INT64_FORMAT "\"/>\n"
!                        "    <xsd:minInclusive value=\"" INT64_FORMAT "\"/>\n"
                                   "  </xsd:restriction>\n",
                                 (((uint64) 1) << (sizeof(int64) * 8 - 1)) - 1,
                                   (((uint64) 1) << (sizeof(int64) * 8 - 1)));
--- 3029,3036 ----
              case INT8OID:
                  appendStringInfo(&result,
                                   "  <xsd:restriction base=\"xsd:long\">\n"
!                        "    <xsd:maxInclusive value=\"" INT64_FORMAT "\" />\n"
!                        "    <xsd:minInclusive value=\"" INT64_FORMAT "\" />\n"
                                   "  </xsd:restriction>\n",
                                 (((uint64) 1) << (sizeof(int64) * 8 - 1)) - 1,
                                   (((uint64) 1) << (sizeof(int64) * 8 - 1)));
***************
*** 3059,3075 ****
                      if (typmod == -1)
                          appendStringInfo(&result,
                                      "  <xsd:restriction base=\"xsd:time\">\n"
!                                          "    <xsd:pattern
value=\"\\p{Nd}{2}:\\p{Nd}{2}:\\p{Nd}{2}(.\\p{Nd}+)?%s\"/>\n"
                                           "  </xsd:restriction>\n", tz);
                      else if (typmod == 0)
                          appendStringInfo(&result,
                                      "  <xsd:restriction base=\"xsd:time\">\n"
!                                          "    <xsd:pattern value=\"\\p{Nd}{2}:\\p{Nd}{2}:\\p{Nd}{2}%s\"/>\n"
                                           "  </xsd:restriction>\n", tz);
                      else
                          appendStringInfo(&result,
                                      "  <xsd:restriction base=\"xsd:time\">\n"
!                                          "    <xsd:pattern
value=\"\\p{Nd}{2}:\\p{Nd}{2}:\\p{Nd}{2}.\\p{Nd}{%d}%s\"/>\n"
                              "  </xsd:restriction>\n", typmod - VARHDRSZ, tz);
                      break;
                  }
--- 3059,3075 ----
                      if (typmod == -1)
                          appendStringInfo(&result,
                                      "  <xsd:restriction base=\"xsd:time\">\n"
!                                          "    <xsd:pattern value=\"\\p{Nd}{2}:\\p{Nd}{2}:\\p{Nd}{2}(.\\p{Nd}+)?%s\"
/>\n"
                                           "  </xsd:restriction>\n", tz);
                      else if (typmod == 0)
                          appendStringInfo(&result,
                                      "  <xsd:restriction base=\"xsd:time\">\n"
!                                          "    <xsd:pattern value=\"\\p{Nd}{2}:\\p{Nd}{2}:\\p{Nd}{2}%s\" />\n"
                                           "  </xsd:restriction>\n", tz);
                      else
                          appendStringInfo(&result,
                                      "  <xsd:restriction base=\"xsd:time\">\n"
!                                          "    <xsd:pattern value=\"\\p{Nd}{2}:\\p{Nd}{2}:\\p{Nd}{2}.\\p{Nd}{%d}%s\"
/>\n"
                              "  </xsd:restriction>\n", typmod - VARHDRSZ, tz);
                      break;
                  }
***************
*** 3082,3098 ****
                      if (typmod == -1)
                          appendStringInfo(&result,
                                  "  <xsd:restriction base=\"xsd:dateTime\">\n"
!                                          "    <xsd:pattern
value=\"\\p{Nd}{4}-\\p{Nd}{2}-\\p{Nd}{2}T\\p{Nd}{2}:\\p{Nd}{2}:\\p{Nd}{2}(.\\p{Nd}+)?%s\"/>\n"
                                           "  </xsd:restriction>\n", tz);
                      else if (typmod == 0)
                          appendStringInfo(&result,
                                  "  <xsd:restriction base=\"xsd:dateTime\">\n"
!                                          "    <xsd:pattern
value=\"\\p{Nd}{4}-\\p{Nd}{2}-\\p{Nd}{2}T\\p{Nd}{2}:\\p{Nd}{2}:\\p{Nd}{2}%s\"/>\n"
                                           "  </xsd:restriction>\n", tz);
                      else
                          appendStringInfo(&result,
                                  "  <xsd:restriction base=\"xsd:dateTime\">\n"
!                                          "    <xsd:pattern
value=\"\\p{Nd}{4}-\\p{Nd}{2}-\\p{Nd}{2}T\\p{Nd}{2}:\\p{Nd}{2}:\\p{Nd}{2}.\\p{Nd}{%d}%s\"/>\n"
                              "  </xsd:restriction>\n", typmod - VARHDRSZ, tz);
                      break;
                  }
--- 3082,3098 ----
                      if (typmod == -1)
                          appendStringInfo(&result,
                                  "  <xsd:restriction base=\"xsd:dateTime\">\n"
!                                          "    <xsd:pattern
value=\"\\p{Nd}{4}-\\p{Nd}{2}-\\p{Nd}{2}T\\p{Nd}{2}:\\p{Nd}{2}:\\p{Nd}{2}(.\\p{Nd}+)?%s\"/>\n" 
                                           "  </xsd:restriction>\n", tz);
                      else if (typmod == 0)
                          appendStringInfo(&result,
                                  "  <xsd:restriction base=\"xsd:dateTime\">\n"
!                                          "    <xsd:pattern
value=\"\\p{Nd}{4}-\\p{Nd}{2}-\\p{Nd}{2}T\\p{Nd}{2}:\\p{Nd}{2}:\\p{Nd}{2}%s\"/>\n" 
                                           "  </xsd:restriction>\n", tz);
                      else
                          appendStringInfo(&result,
                                  "  <xsd:restriction base=\"xsd:dateTime\">\n"
!                                          "    <xsd:pattern
value=\"\\p{Nd}{4}-\\p{Nd}{2}-\\p{Nd}{2}T\\p{Nd}{2}:\\p{Nd}{2}:\\p{Nd}{2}.\\p{Nd}{%d}%s\"/>\n" 
                              "  </xsd:restriction>\n", typmod - VARHDRSZ, tz);
                      break;
                  }
***************
*** 3100,3106 ****
              case DATEOID:
                  appendStringInfo(&result,
                                   "  <xsd:restriction base=\"xsd:date\">\n"
!                                  "    <xsd:pattern value=\"\\p{Nd}{4}-\\p{Nd}{2}-\\p{Nd}{2}\"/>\n"
                                   "  </xsd:restriction>\n");
                  break;

--- 3100,3106 ----
              case DATEOID:
                  appendStringInfo(&result,
                                   "  <xsd:restriction base=\"xsd:date\">\n"
!                                  "    <xsd:pattern value=\"\\p{Nd}{4}-\\p{Nd}{2}-\\p{Nd}{2}\" />\n"
                                   "  </xsd:restriction>\n");
                  break;

***************
*** 3113,3119 ****
                      base_typeoid = getBaseTypeAndTypmod(typeoid, &base_typmod);

                      appendStringInfo(&result,
!                                      "  <xsd:restriction base=\"%s\"/>\n",
                          map_sql_type_to_xml_name(base_typeoid, base_typmod));
                  }
                  break;
--- 3113,3119 ----
                      base_typeoid = getBaseTypeAndTypmod(typeoid, &base_typmod);

                      appendStringInfo(&result,
!                                      "  <xsd:restriction base=\"%s\" />\n",
                          map_sql_type_to_xml_name(base_typeoid, base_typmod));
                  }
                  break;
***************
*** 3168,3174 ****
          if (isnull)
          {
              if (nulls)
!                 appendStringInfo(result, "  <%s xsi:nil='true'/>\n", colname);
          }
          else
              appendStringInfo(result, "  <%s>%s</%s>\n",
--- 3168,3174 ----
          if (isnull)
          {
              if (nulls)
!                 appendStringInfo(result, "  <%s xsi:nil='true' />\n", colname);
          }
          else
              appendStringInfo(result, "  <%s>%s</%s>\n",
*** ./src/backend/utils/adt/xml.c.orig    2007-11-23 02:17:55.000000000 -0200
--- ./src/backend/utils/adt/xml.c    2007-11-23 02:21:31.000000000 -0200
***************
*** 3019,3025 ****

              case INT4OID:
                  appendStringInfo(&result,
!                                  "  <xsd:restriction base='xsd:int'>\n"
                                   "    <xsd:maxInclusive value=\"%d\" />\n"
                                   "    <xsd:minInclusive value=\"%d\" />\n"
                                   "  </xsd:restriction>\n",
--- 3019,3025 ----

              case INT4OID:
                  appendStringInfo(&result,
!                                  "  <xsd:restriction base=\"xsd:int\">\n"
                                   "    <xsd:maxInclusive value=\"%d\" />\n"
                                   "    <xsd:minInclusive value=\"%d\" />\n"
                                   "  </xsd:restriction>\n",
***************
*** 3168,3174 ****
          if (isnull)
          {
              if (nulls)
!                 appendStringInfo(result, "  <%s xsi:nil='true' />\n", colname);
          }
          else
              appendStringInfo(result, "  <%s>%s</%s>\n",
--- 3168,3174 ----
          if (isnull)
          {
              if (nulls)
!                 appendStringInfo(result, "  <%s xsi:nil=\"true\" />\n", colname);
          }
          else
              appendStringInfo(result, "  <%s>%s</%s>\n",

Re: BUG #3734: Invalid XML schema output.

От
Tom Lane
Дата:
Euler Taveira de Oliveira <euler@timbira.com> writes:
> Bruce Momjian wrote:
>>> Agreed. Feel free to add whitespace before every /> of simple xml elements.
>>
>> Uh, was this done?
>>
> Nope. Attached is a patch that does it.

Er ... why exactly is it a good idea to bloat XML output with cosmetic
whitespace?  I should think that only programs, not humans, read XML for
the most part.

> I'm attaching another cosmetic
> patch that replaces the use of some single quotes with double quotes in
> the XML attributes output.

This part sounds like a good idea, if only because single quotes require
doubling in some situations in SQL-land.

            regards, tom lane

Re: BUG #3734: Invalid XML schema output.

От
Bruce Momjian
Дата:
Tom Lane wrote:
> Euler Taveira de Oliveira <euler@timbira.com> writes:
> > Bruce Momjian wrote:
> >>> Agreed. Feel free to add whitespace before every /> of simple xml elements.
> >>
> >> Uh, was this done?
> >>
> > Nope. Attached is a patch that does it.
>
> Er ... why exactly is it a good idea to bloat XML output with cosmetic
> whitespace?  I should think that only programs, not humans, read XML for
> the most part.

I assumed XML is for both human and program reading;  in fact, I thought
that was its big benefit.  I assume we are taking the difference between
"<br/>" vs "<br />", right?  I will admit I don't know much about XML.

--
  Bruce Momjian  <bruce@momjian.us>        http://momjian.us
  EnterpriseDB                             http://postgres.enterprisedb.com

  + If your life is a hard drive, Christ can be your backup. +

Re: BUG #3734: Invalid XML schema output.

От
"Harald Armin Massa"
Дата:
>
> I assumed XML is for both human and program reading;  in fact, I thought
> that was its big benefit.  I assume we are taking the difference between
> "<br/>" vs "<br />", right?  I will admit I don't know much about XML.
>
>
within XHTML it is recommended to use <br />, because some parsers will not
parse it correctly without that space. I guess some pure XML-Parsers may
have the same problem (and be it only the IE-XML-Parser)

Harald

--=20
GHUM Harald Massa
persuadere et programmare
Harald Armin Massa
Spielberger Stra=DFe 49
70435 Stuttgart
0173/9409607
fx 01212-5-13695179
-
EuroPython 2008 will take place in Vilnius, Lithuania - Stay tuned!

Re: BUG #3734: Invalid XML schema output.

От
Michael Glaesemann
Дата:
On Nov 23, 2007, at 11:22 , Harald Armin Massa wrote:

> within XHTML it is recommended to use <br />, because some parsers
> will not parse it correctly without that space.

It's because some browser *HTML* parsers that aren't fully XML
compliant won't parse it correctly, not because some XML parsers have
a problem with it. Any XML parser worthy of the name should have no
problem with <br/> (or any other self-closing empty element tag, for
that matter).

Michael Glaesemann
grzm seespotcode net

Re: BUG #3734: Invalid XML schema output.

От
Peter Eisentraut
Дата:
Am Freitag, 23. November 2007 schrieb Michael Glaesemann:
> It's because some browser *HTML* parsers that aren't fully XML  
> compliant won't parse it correctly

Yes, that is pretty much it, but that is obviously irrelevant nowadays and for
us, especially.  Some sources seem to use it for stylistic reasons, but I
fail to see the advantage.

--
Peter Eisentraut
http://developer.postgresql.org/~petere/

Re: BUG #3734: Invalid XML schema output.

От
Michael Glaesemann
Дата:
On Nov 23, 2007, at 12:30 , Peter Eisentraut wrote:

> Am Freitag, 23. November 2007 schrieb Michael Glaesemann:
>> It's because some browser *HTML* parsers that aren't fully XML
>> compliant won't parse it correctly
>
> Yes, that is pretty much it, but that is obviously irrelevant
> nowadays and for
> us, especially.  Some sources seem to use it for stylistic reasons,
> but I
> fail to see the advantage.

Agreed.

Michael Glaesemann
grzm seespotcode net

Re: BUG #3734: Invalid XML schema output.

От
Peter Eisentraut
Дата:
Euler Taveira de Oliveira wrote:
> Bruce Momjian wrote:
> >> Agreed. Feel free to add whitespace before every /> of simple xml
> >> elements.
> >
> > Uh, was this done?
>
> Nope. Attached is a patch that does it. I'm attaching another cosmetic
> patch that replaces the use of some single quotes with double quotes in
> the XML attributes output.

I have committed the quoting changes.

--
Peter Eisentraut
http://developer.postgresql.org/~petere/