Skip site navigation (1) Skip section navigation (2)

Re: xpath processing brain dead

From: James Pye <lists(at)jwp(dot)name>
To: James Pye <lists(at)jwp(dot)name>
Cc: Andrew Dunstan <andrew(at)dunslane(dot)net>, 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-02-28 10:51:27
Message-ID: 278C752B-226C-4E2D-B683-D49760F5086D@jwp.name (view raw or flat)
Thread:
Lists: pgsql-hackers
sigh.. I got curious. :P

On Feb 27, 2009, at 7:19 PM, James Pye wrote:
> Well, that or force the user to call it explicitly.


Attached is the patch that I used to get the results below..
This is just a proof of concept, so it's quite lacking. Notably, it  
doesn't even try to identify well-formed documents.


Purpose/idea being, give the user access to the poorly-formed document  
as a node-set via the "fragment" function instead of mangling the  
xpath and xml:


postgres=# SELECT xpath('fragment()//*', 'bleh<foo/><bar/>'::xml);
  xpath
-------
  {}
(1 row)

postgres=# SELECT xpath('fragment()//*', 'bleh<meh><sub/></meh><foo/ 
 ><bar/>'::xml);
   xpath
----------
  {<sub/>}
(1 row)

postgres=# SELECT xpath('fragment()/*', 'bleh<meh><sub/></meh><foo/ 
 ><bar/>'::xml);
   xpath
----------
  {<sub/>}
(1 row)

postgres=# SELECT xpath('fragment()', 'bleh<meh><sub/></meh><foo/><bar/ 
 >'::xml);
          xpath
------------------------
  {bleh,"<meh>
    <sub/>
  </meh>",<foo/>,<bar/>}
(1 row)

postgres=# SELECT xpath('/*', 'bleh<meh><sub/></meh><foo/><bar/>'::xml);
  xpath
-------
  {}
(1 row)

postgres=# SELECT xpath('fragment()[local-name()="foo"]/@att',
  'bleh<meh><sub/></meh><foo att="sometin"/><bar/>'::xml);
    xpath
-----------
  {sometin}
(1 row)

postgres=# SELECT xpath('fragment()[local-name()="meh"]/*',
'bleh<meh><sub/></meh><foo att="sometin"/><bar/>'::xml);
   xpath
----------
  {<sub/>}
(1 row)

postgres=# SELECT xpath('fragment()[local-name()="meh" or local- 
name()="bar"]', 'bleh<meh><sub/></meh><foo att="sometin"/><bar/>'::xml);
       xpath
-----------------
  {"<meh>
    <sub/>
  </meh>",<bar/>}
(1 row)

postgres=# SELECT xpath('fragment()[local-name()="bar"]',
'bleh<meh><sub/></meh><foo att="sometin"/><bar/>'::xml);
   xpath
----------
  {<bar/>}
(1 row)

postgres=# SELECT xpath('fragment()[(at)*]',
'bleh<meh><sub/></meh>othertext<foo att="sometin"/><bar/>'::xml);
            xpath
----------------------------
  {"<foo att=\"sometin\"/>"}
(1 row)


Can't say that I've ever been thrilled with using node-sets, but  
*shrug*.

I'm sleepy now..


Attachment: xmlc_file.diff
Description: application/octet-stream (5.6 KB)
Attachment: git.diff
Description: application/octet-stream (5.7 KB)

In response to

Responses

pgsql-hackers by date

Next:From: Gregory StarkDate: 2009-02-28 11:37:55
Subject: Re: would it be a lot of work, to add optimizations accross unions ?
Previous:From: Grzegorz JaskiewiczDate: 2009-02-28 10:44:32
Subject: would it be a lot of work, to add optimizations accross unions ?

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group