| 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 | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| 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 | Content-Type | Size | 
|---|---|---|
| git.diff | application/octet-stream | 5.7 KB | 
| xmlc_file.diff | application/octet-stream | 5.6 KB | 
| unknown_filename | text/plain | 1 byte | 
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Gregory Stark | 2009-02-28 11:37:55 | Re: would it be a lot of work, to add optimizations accross unions ? | 
| Previous Message | Grzegorz Jaskiewicz | 2009-02-28 10:44:32 | would it be a lot of work, to add optimizations accross unions ? |