PostgreSQL 8.3 XML parser seems not to recognize the DOCTYPE element in XML files

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

PostgreSQL 8.3 XML parser seems not to recognize the DOCTYPE element in XML files

От:
"Lawrence Oluyede" <l.oluyede@gmail.com>
Дата:
As specified in the W3C Recommendation for XML the DOCTYPE element is
perfectly valid in a document.
I have a bunch of XML files generated by the boost library which
contains a doctype like this:



which lies within the bound of the recommendation
(http://www.w3.org/TR/xml/#sec-prolog-dtd):

"Note that it is possible to construct a well-formed document
containing a doctypedecl that neither points to an external subset nor
contains an internal subset."

PostgreSQL 8.3 instead doesn't allow the insertion of XML with doctype
in its new native data type returning this error message:

"""
ERROR:  invalid XML content
DETAIL:  Entity: line 2: parser error : StartTag: invalid element name

 ^

********** Error **********

ERROR: invalid XML content
SQL state: 2200N
Detail: Entity: line 2: parser error : StartTag: invalid element name

"""

This kind of behavior surprises me because pgsql has been compiled
with the following flags on the development machine:
 ./configure --with-python --with-openssl --with-pam --with-libxml
--with-libxslt --enable-thread-safety --enable-debug

During the configuration stage it creates a Makefile binding the
system version of the libxml2 library which is 2.6.30, the same
library I use through Python (which parses correctly the XML file with
the doctype).

Any hints?

Re: PostgreSQL 8.3 XML parser seems not to recognize the DOCTYPE element in XML files

От:
Bruce Momjian <bruce@momjian.us>
Дата:

Added to TODO:

* Allow XML to accept more liberal DOCTYPE specifications

  http://archives.postgresql.org/pgsql-general/2008-02/msg00347.php


---------------------------------------------------------------------------

Lawrence Oluyede wrote:
> As specified in the W3C Recommendation for XML the DOCTYPE element is
> perfectly valid in a document.
> I have a bunch of XML files generated by the boost library which
> contains a doctype like this:
> 
> 
> 
> which lies within the bound of the recommendation
> (http://www.w3.org/TR/xml/#sec-prolog-dtd):
> 
> "Note that it is possible to construct a well-formed document
> containing a doctypedecl that neither points to an external subset nor
> contains an internal subset."
> 
> PostgreSQL 8.3 instead doesn't allow the insertion of XML with doctype
> in its new native data type returning this error message:
> 
> """
> ERROR:  invalid XML content
> DETAIL:  Entity: line 2: parser error : StartTag: invalid element name
> 
>  ^
> 
> ********** Error **********
> 
> ERROR: invalid XML content
> SQL state: 2200N
> Detail: Entity: line 2: parser error : StartTag: invalid element name
> 
> """
> 
> This kind of behavior surprises me because pgsql has been compiled
> with the following flags on the development machine:
>  ./configure --with-python --with-openssl --with-pam --with-libxml
> --with-libxslt --enable-thread-safety --enable-debug
> 
> During the configuration stage it creates a Makefile binding the
> system version of the libxml2 library which is 2.6.30, the same
> library I use through Python (which parses correctly the XML file with
> the doctype).
> 
> Any hints?
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 9: In versions below 8.0, the planner will ignore your desire to
>        choose an index scan if your joining column's datatypes do not
>        match

-- 
  Bruce Momjian          http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

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

Re: PostgreSQL 8.3 XML parser seems not to recognize the DOCTYPE element in XML files

От:
Kevin Grittner <kevin.grittner@wicourts.gov>
Дата:
Bruce Momjian wrote:
> Added to TODO:
> 
> * Allow XML to accept more liberal DOCTYPE specifications

Is any form of DOCTYPE accepted?

We're getting errors on the second line like this:




The actual host.domain value is resolved by DNS,
and wget of the url works on the machine.
Attempts to cast the document to type xml give:

ERROR:  invalid XML content
DETAIL:  Entity: line 2: parser error : StartTag: invalid element name
DOCTYPE DOT_OFFICER_CITATION SYSTEM "http://host.domain/dtd/dot
^

It would be nice to use the xml type, but we always have DOCTYPE....

-Kevin

Re: PostgreSQL 8.3 XML parser seems not to recognize the DOCTYPE element in XML files

От:
Kevin Grittner <kevin.grittner@wicourts.gov>
Дата:
Bruce Momjian wrote:
> Added to TODO:
> 
> * Allow XML to accept more liberal DOCTYPE specifications

Is any form of DOCTYPE accepted?

We're getting errors on the second line like this:




The actual host.domain value is resolved by DNS,
and wget of the url works on the machine.
Attempts to cast the document to type xml give:

ERROR:  invalid XML content
DETAIL:  Entity: line 2: parser error : StartTag: invalid element name
DOCTYPE DOT_OFFICER_CITATION SYSTEM "http://host.domain/dtd/dot
^

It would be nice to use the xml type, but we always have DOCTYPE....

-Kevin

Re: PostgreSQL 8.3 XML parser seems not to recognize the DOCTYPE element in XML files

От:
Kevin Grittner <kevin.grittner@wicourts.gov>
Дата:
Bruce Momjian wrote:
> Added to TODO:
> 
> * Allow XML to accept more liberal DOCTYPE specifications

Is any form of DOCTYPE accepted?

We're getting errors on a second line in an XML document that
starts like this:




The actual host.domain value is resolved by DNS,
and wget of the url works on the server running PostgreSQL.
Attempts to cast the document to type xml give:

ERROR:  invalid XML content
DETAIL:  Entity: line 2: parser error : StartTag: invalid element name
DOCTYPE DOT_OFFICER_CITATION SYSTEM "http://host.domain/dtd/dot
^

It would be nice to use the xml type, but we always have DOCTYPE.
I understand that PostgreSQL won't validate against the specified
DOCTYPE, but it shouldn't error out on it, either.

-Kevin

Re: PostgreSQL 8.3 XML parser seems not to recognize the DOCTYPE element in XML files

От:
Peter Eisentraut <peter_e@gmx.net>
Дата:
Am Thursday, 7. February 2008 schrieb Lawrence Oluyede:
> PostgreSQL 8.3 instead doesn't allow the insertion of XML with doctype
> in its new native data type returning this error message:
>
> """
> ERROR:  invalid XML content
> DETAIL:  Entity: line 2: parser error : StartTag: invalid element name
> 
>  ^

It turns out that this behavior is entirely correct.  It depends on the XML 
option.  If you set the XML option to DOCUMENT, you can parse documents 
including DOCTYPE declarations.  If you set the XML option to CONTENT, then 
what you can parse is defined by the production

XMLDecl? content

which does not allow for a DOCTYPE.

The default XML option is CONTENT, which explains the behavior.

Now, the supercorrect way to parse XML values would be using the XMLPARSE() 
function, which requires you to specify the XML option inline.  That way, 
everything works.
FAQ