[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: GSXPathContext examples ?
From: |
Philippe Roussel |
Subject: |
Re: GSXPathContext examples ? |
Date: |
Sat, 5 Jan 2008 22:41:56 +0100 |
User-agent: |
Mutt/1.5.11 |
On Sat, Jan 05, 2008 at 10:03:28PM +0100, Nicola Pero wrote:
> There is no syntax in XPath itself to declare a namespace; you have first to
> use a separate API (dependent on the XML library in use) to tell the XML
> parser
> about what mappings between prefixes and namespaces you want to use, then you
> can use these prefixes in your XPath expressions.
>
> libxml2 has this API but GSXPath was missing a wrapper method - I added it in
> subversion. You should still be able to do it manually in older releases as
> follows
> (untested) --
>
> if ((xmlXPathRegisterNs ([p lib], "D", "DAV:") != 0)
> ||(xmlXPathRegisterNs ([p lib], "ap", "http://apache.org/dav/props") !=
> 0))
> {
> /* Error registering namespaces; do something about it. */
> }
>
> (then a query as in "//D:href" should work)
It works, thanks a lot for the tip !
> If you're using gnustep-base from trunk, you can try
>
> if (![p registerNamespaceWithPrefix: @"D" href="DAV:"]
> || (![p registerNamespaceWithPrefix: @"ap"
> href="http://apache.org/dav/props/"]))
> {
> /* Error registering namespaces; do something about it. */
> }
>
> which does exactly the same thing (I tried this one, and it works for me). :-)
Great. I'll add both versions to my code until this new method hits
gnustep-stable (which could be a while I guess).
Thanks again for your help and reactivity,
Philippe
--
Never argue with an idiot. They drag you down to their level, then beat you
with experience