BUG #3734: Invalid XML schema output.
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>
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/
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
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/
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/
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. +
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/
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. +
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/
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
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. +
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
--
GHUM Harald Massa
persuadere et programmare
Harald Armin Massa
Spielberger Straße 49
70435 Stuttgart
0173/9409607
fx 01212-5-13695179
-
EuroPython 2008 will take place in Vilnius, Lithuania - Stay tuned!
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
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/
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 correctlyYes, 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
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/