xmlns in xpath query

From: Frank Glandorf <frank(dot)glandorf(at)gmail(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: xmlns in xpath query
Date: 2009-09-19 02:13:36
Message-ID: ec29055e0909181913g3cc77d6ej51ba155be128d003@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Using postgresql v8.3 and xml xpath query function and having trouble with
xmlns. Note: the select statements were originally all on a single line.

The xpath function works ok if the xmlns attributes are missing.

select xpath('/gpx', '<gpx version="1.0" creator="GPSBabel -
http://www.gpsbabel.org">abc</gpx>');

xpath
-----------------------------------------------------------------------------------
{"<gpx version=\"1.0\" creator=\"GPSBabel - http://www.gpsbabel.org
\">abc</gpx>"}
(1 row)

The xpath function gives no result when xmlns attributes are supplied.

select xpath('/gpx', '<gpx xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance" xmlns="
http://www.topografix.com/GPX/1/0" version="1.0" creator="GPSBabel -
http://www.gpsbabel.org" xsi:schemaLocation="
http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd
">abc</gpx>');

xpath
-------
{}
(1 row)

Setting the optional name space attributes for the xpath function also gives
no results.

select xpath('/gpx', '<gpx xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance" xmlns="
http://www.topografix.com/GPX/1/0" version="1.0" creator="GPSBabel -
http://www.gpsbabel.org" xsi:schemaLocation="
http://www.topografix.com/GPX/1/0
http://www.topografix.com/GPX/1/0/gpx.xsd">abc</gpx>',
array[array['xsi','http://www.w3.org/2001/XMLSchema-instance'],array['','
http://www.topografix.com/GPX/1/0']]);

xpath
-------
{}
(1 row)

Suggestions?

-Frank

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Frank Glandorf 2009-09-19 02:43:46 Re: xmlns in xpath query
Previous Message Tom Lane 2009-09-18 15:11:48 Re: Index not used in join.. (example included).