[GENERAL] How to check if an array is empty

2008-09-11 Thread Tobias Anstett
Hi,

 

in my special case I'd like to check if a XML[] is empty, because postgres
doesn't implement any equality operators, this is not a 'simple' task.

 

My current solution is:

 

SELECT * FROM sometable WHERE XMLSERIALIZE(CONTENT ((XPATH('/a:bar,
somexmlcolumn, ARRAY[ARRAY['a', 'http://foo]]))[1]) AS text)''

 

But there must be a better way - maybe I missed something important - I also
tried queries like the following:

 

SELECT * FROM sometable WHERE (XPATH('/a:bar', somexmlcolumn,
ARRAY[ARRAY['a', 'http://foo']]))('{}'::XML[])

 

Any ideas and feedback are welcome.

 

Cheers, Tobias 



[GENERAL] xml2 vs XMLFunctions

2008-09-04 Thread Tobias Anstett
Hi,

 

I am currently using xml2 functionality in PostgreSQL 8.3.x and want to
substitute it by the newer API as mentioned here:

 

From PostgreSQL 8.3 on, there is XML-related functionality based on the
SQL/XML standard in the core server. That functionality covers XML syntax
checking and XPath queries, which is

what this module does, and more, but the API is not at all compatible. It
is planned that this module will be removed in PostgreSQL 8.4 in favor of
the newer standard API, so you are 

encouraged to try converting your applications. If you find that some of
the functionality of this module is not available in an adequate form with
the newer API, please explain your 

issue to [EMAIL PROTECTED] so that the deficiency can be
addressed.

 

The only function of xml2 I ever used was xpath_bool(document,query)
returns bool where document represents a table column. How can I do this
with the new API ?

I thought that 9.14.2. Processing XML: xpath(xpath, xml[, nsarray]) might
be the right function, but I don't know how to specify the column where the
xml is stored.

Can you please give me an example ? I only have to implement xpath functions
that return Boolean. I'd like to query - SELECT foo FROM bar AS x WHERE
xpath('xpath', x.xmlcolumn [,nsarray])

 

 

Cheers, Tobias

 



[GENERAL] xpath_bool_ns() and xml2

2008-09-04 Thread Tobias Anstett
Hi,

 

does anybody know how to use the xml2 function xpath_bool with namespaces. 

I have used this function successfully as long as my xml documents haven't
contained namespaces. I searched with google and found some readme file
where the function xpath_bool_ns was available that would probably resolve
my namespace aware xml xpath issue, but this function isn't contained in the
pqxml.dll that comes with postgres 8.3.3.

 

Can anybody help me or point some other solution ? I just want to do some
xpath queries on a table column that returns a Boolean as result.

 

Cheers, Tobias