Re: Svar: Re: [xml] XPath problem with namespaces



That won't work because you can have a doc that looks like this:

<a:foo xmlns:a="ns1">
  <a:bar></a:bar>
  <a:other>
      <a:bar xmlns:a="ns2"></a:bar>
   </a:other>
</a:foo>

Which bar element would //a:bar refer to?  Would /a:foo/a:other/a:bar find an element?
It just doesn't work.

The xmllint shell does need someway to specify prefix<->namespace mappings.  
It not very useful without that.

*----

Date: Tue, 8 Jun 2004 08:08:48 +0200
From: "Erik F. Andersen" <ea ascott dk>
Thanks,

that was it. I knew I knew it, there was just too much info at once ;-) But why can't it simply register all 
the namespaces from the document itself in xmlXPathNewContext?

- Erik

Daniel Veillard<veillard redhat com> 07-06-2004 23:55:18 >>>

On Mon, Jun 07, 2004 at 09:40:00PM +0200, Erik F. Andersen wrote:
No, it doesn't work. About the only expression I can get to work is something like //*. This will return 
the Envelope (as expected) node as the first node in the result. The namespace for this node is SOAP-ENV 
(also as expected).

  You *must* provide the namespace declaration to the prefix used.
Read the example it shows how to bind namespaces to XPath evaluation context !
   http://xmlsoft.org/examples/index.html#xpath1.c






[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]