Re: xpath_array with namespaces support - Mailing list pgsql-patches

From Peter Eisentraut
Subject Re: xpath_array with namespaces support
Date
Msg-id 200704041544.43371.peter_e@gmx.net
Whole thread Raw
In response to Re: xpath_array with namespaces support  (Bruce Momjian <bruce@momjian.us>)
List pgsql-patches
Am Mittwoch, 4. April 2007 15:20 schrieb Nikolay Samokhvalov:
> > To determine if an XML datum is a document, call xml_is_document().  The
> > implementation of that function is probably not the best possible one,
> > but what the xpath() code does it totally wrong nevertheless.
>
> You are proposing 2-3 (depends on the case) parsing times for the one XML
> value instead of current 1-2

I know it's bad, and something like adding a bit (byte) to mark this in the
value would be good, but that doesn't change the fact that

(xmlStrncmp((xmlChar *) VARDATA(data), (xmlChar *) "<?xml", 5) == 0)

is not a valid method to tell apart a document from a fragment.  Proof:

pei=# select xml '<?xml version="1.0"?><foo>bar</foo>' IS DOCUMENT;
 ?column?
----------
 t
(1 row)

pei=# select xml '<?xml version="1.0"?><foo>bar</foo><foo>bar</foo>' IS
DOCUMENT;
 ?column?
----------
 f
(1 row)

pei=# select xml '<foo>bar</foo>' IS DOCUMENT;
 ?column?
----------
 t
(1 row)

pei=# select xml '<foo>bar</foo><foo>bar</foo>' IS DOCUMENT;
 ?column?
----------
 f
(1 row)

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

pgsql-patches by date:

Previous
From: Peter Eisentraut
Date:
Subject: Re: xpath_array with namespaces support
Next
From: "Nikolay Samokhvalov"
Date:
Subject: Re: xpath_array with namespaces support