Re: xpath_array with namespaces support

From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: "Nikolay Samokhvalov" <nikolay(at)samokhvalov(dot)com>
Cc: pgsql-patches(at)postgresql(dot)org, "Bruce Momjian" <bruce(at)momjian(dot)us>
Subject: Re: xpath_array with namespaces support
Date: 2007-04-04 13:44:42
Message-ID: 200704041544.43371.peter_e@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers 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/

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrew - Supernews 2007-04-04 13:45:28 Re: Bug in UTF8-Validation Code?
Previous Message Nikolay Samokhvalov 2007-04-04 13:43:11 Re: [PATCHES] xpath_array with namespaces support

Browse pgsql-patches by date

  From Date Subject
Next Message Gregory Stark 2007-04-04 14:03:51 Re: Auto Partitioning
Previous Message Nikolay Samokhvalov 2007-04-04 13:43:11 Re: [PATCHES] xpath_array with namespaces support