Re: xpath improvement suggestion - Mailing list pgsql-hackers

From Peter Eisentraut
Subject Re: xpath improvement suggestion
Date
Msg-id 1263194527.4609.4.camel@fsopti579.F-Secure.com
Whole thread Raw
In response to Re: xpath improvement suggestion  (Arie Bikker <arie@abikker.nl>)
Responses Re: xpath improvement suggestion  (Arie Bikker <arie@abikker.nl>)
List pgsql-hackers
On ons, 2010-01-06 at 23:46 +0100, Arie Bikker wrote:
> Hope this is the right attachement type (I'm new at this)
> BTW. here a some nice examples:
> 
> - Get the number of attributes of the first childnode:
> 
> select ( xpath('count(@*)',(xpath('*[1]','<a b="c"><d e="f" 
> g="j"/></a>'))[1]))[1];
> 
> - an alternative for xpath_exist('/a/d')
> select (xpath('boolean(/a/d)','<a b="c"><d e="f" g="j"/></a>'))[1];
> 
> - fixes bug 4206
> 
> select xpath('//text()',xmlparse(document '<?xml 
> version="1.0"?><elem1><elem2>one</elem2><elem2>two</elem2><elem2>three</elem2><elem3att="2"/></elem1>'));
> 
> - fixes bug 4294
> 
> select xpath('name(/my:a/*[last()])', '<a 
> xmlns="http://myns.com/ns"><b>text1</b><c>text2</c></a>', 
> ARRAY[ARRAY['my','http://myns.com/ns']]); 

Instead of converting everything to text, there have been previous
suggestions to add functionx like xpath_string, xpath_number,
xpath_boolean that return the appropriate types from xpath.  This could
provide for better type safety and probably also more clarity.

In any case, please consider adding test cases like the above to the
regression tests in whatever patch comes out at the end.



pgsql-hackers by date:

Previous
From: Peter Eisentraut
Date:
Subject: Re: Typed tables
Next
From: Craig Ringer
Date:
Subject: Re: Streaming replication status