Dan Allen ([EMAIL PROTECTED]) wrote:

> I was testing out this function today (xpath_register_ns) and I
> found a possible problem in its implementation.  If you use several
> namespaces in you document and then define a last one to be the
> default namespace, how are you supposed to register this with the
> php function.  Example:
> 
>  <?xml version="1.0" encoding="utf-8"?>
>  <rdf:RDF
>    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#";
>    xmlns:dc="http://purl.org/dc/elements/1.1/";
>    xmlns:pl="http://mojavelinux.com/rss/1.0/modules/places";
>    xmlns="http://purl.org/rss/1.0/";
>  >
>    <channel rdf:about="http://mojave.mojavelinux.com/newsletter/";>
>      <title>Local Sights and Attractions in Washington/Balimore for the Dan &amp; 
>Sarah Wedding</title>
>      <link>http://mojave.mojavelinux.com/newsletter/</link>
>      <description>Places in the Washington/Baltimore area where our guest may 
>entertain themselves.</description>
> (clip...)
> 
> Now if you run the query
> 
>  $ctx->xpath_register_ns('rdf', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#');
>  $ctx->xpath_register_ns('dc', 'http://purl.org/dc/elements/1.1/');
>  $ctx->xpath_register_ns('pl', 'http://mojavelinux.com/rss/1.0/modules/places');
>  $ctx->xpath_register_ns('', 'http://purl.org/rss/1.0/');
>  $ctx->xpath_eval('//channel');
> 
> You get no results.  However, if you replace the last namespace
> declaration with the name of 'rss' and change call the tags to
> <rss:*> and then do the query
> 
>  $ctx->xpath_eval('//rss:channel');
> 
> You get the expected results.  So basically, it seems that the
> xpath_register_ns function does not allow you to register a default
> namespace.
> 

As a follow up to this, how are you supposed to tell what namespaces
the xml document has...should this be done automatically?

Dan

-- 
________________________________________________________________
Daniel Allen, <[EMAIL PROTECTED]>
http://www.mojavelinux.com/
________________________________________________________________
There is no such thing as a casual knowledge of xslt, either 
you know everything about it or you are sitting in the creek.
________________________________________________________________

-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to