Re: xpath processing brain dead

From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: Hannu Krosing <hannu(at)2ndQuadrant(dot)com>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Peter Eisentraut <peter_e(at)gmx(dot)net>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>, Nikolay Samokhvalov <samokhvalov(at)gmail(dot)com>
Subject: Re: xpath processing brain dead
Date: 2009-03-01 23:22:46
Message-ID: 49AB18C6.80508@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hannu Krosing wrote:
> On Sun, 2009-03-01 at 10:13 -0500, Andrew Dunstan wrote:
>
>> Hannu Krosing wrote:
>>
>>>> Some of the functions, including some specified in the standard, produce
>>>> fragments. That's why we have the 'IS DOCUMENT' test.
>>>>
>>>>
>>> But then you could use xmlfragments as the functions return type, no ?
>>>
>>> Does tha standard require that the same field type must store both
>>> documents and fragments ?
>>>
>>>
>>>
>> Yes, the standard very explicitly provides for one XML type which need
>> not be an XML document. We have no choice about that.
>>
>
> What is it then ? A sequence of XML elements ?
>

In its typically oblique way, the 2003 draft says this:

NOTE 1 — An XML root information item is similar to an XML document
information item, with the following modifications: an
XML root information item does not have a [document element]
property, a [base URI] property, a [character encoding scheme] property,
or an [all declarations processed] property; and the [children]
property permits more than one XML element information item.

An SQL/XML information item is either an XML root information item
or one of the following (defined in
Subclause 3.1.3, “Definitions provided in Part 14”): an XML
attribute information item, an XML character
information item, an XML comment information item, an XML document
type declaration information item,
an XML element information item, an XML namespace information item,
an XML notation information item,
an XML processing instruction information item, an XML unexpanded
entity reference information item, or
an XML unparsed entity information item.

An XML value is either the null value, or a collection of SQL/XML
information items, consisting of exactly
one XML root information item, plus any other SQL/XML information
items that can be reached recursively
by traversing the properties of the SQL/XML information items.

> Which standard does postgreSQL XML type need to confirm to - general XML
> DB, Xpath or some other XML ?
>

I think the XML type needs to conform to the SQL/XML spec. However, we
are trying to apply XPath, which has a different data model, to that
type - hence the impedance mismatch.

I think that the best we can do (for 8.4, having fixed 8.3 as best we
can without adversely changing behaviour) is to throw the responsibility
for ensuring that the XML passed to the function is an XML document back
on the programmer. Anything else, especially any mangling of the XPath
expression, presents a very real danger of breaking on correct input.

cheers

andrew

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Gregory Stark 2009-03-01 23:37:24 Re: cardinality()
Previous Message Hannu Krosing 2009-03-01 22:35:22 Re: xpath processing brain dead