Re: xmlns in xpath query

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

Other examples. A definition for the default name space causes a failure.

glandorf_webmaps=> select xpath('/gpx','<gpx xmlns="http://example.com"
version="1.0">abc</gpx>') from trips where trip_id=90;
xpath
-------
{}
(1 row)
glandorf_webmaps=> select xpath('/gpx','<gpx xmlns:aaa="http://example.com"
version="1.0">abc</gpx>') from trips where trip_id=90;
xpath
---------------------------------------------------------------------
{"<gpx xmlns:aaa=\"http://example.com\" version=\"1.0\">abc</gpx>"}
(1 row)
glandorf_webmaps=> select xpath('/gpx','<gpx xmlns="http://example.com"
version=
"1.0">abc</gpx>',array[array['gpx','http://example.com']]) from trips where
trip_id=90;
xpath
-------
{}
(1 row)

On Fri, Sep 18, 2009 at 10:13 PM, Frank Glandorf
<frank(dot)glandorf(at)gmail(dot)com>wrote:

> 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'<http://www.w3.org/2001/XMLSchema-instance%27>
> ],array['','http://www.topografix.com/GPX/1/0']]<http://www.topografix.com/GPX/1/0%27%5D%5D>
> );
>
> xpath
> -------
> {}
> (1 row)
>
>
> Suggestions?
>
> -Frank
>
>

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Bhushan Verma 2009-09-21 05:53:09 Databse installation problem
Previous Message Frank Glandorf 2009-09-19 02:13:36 xmlns in xpath query