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

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



On Tue, Jun 08, 2004 at 09:36:14AM +0200, Fabrice Desré - France Telecom R&D/DTL/TAL wrote:
> Erik F. Andersen wrote:
> >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?
> 
>  Because there's no way to predict which prefix will be used in the 
> instance (you can even use a default namespace). So you have to bind the 
> prefix that you will use in the xpath expression, and it can be 
> different from the prefix in the document.

  it's worse than that. Namespace scope is a subtree. You can have 
different prefixes mapped to different namespace in different subtrees.

<top>
  <t xmlns:ns='a'><ns:foo/></t>
  <t xmlns:ns='b'><ns:foo/></t>
</top>

  is perfectly legal as a namespaced document.
If people take the time to read the conformance section of the XPath spec
they will discover that there is no conformance for XPath as-is. The XPath
spec was not designed to be used standalone, but reused by XSLT and XPointer.
As a result the spec does not explain how to apply XPath to a document
or tree, how the evaluation context is initialized was left to be described
by the other specs reusing it.

Daniel
 
-- 
Daniel Veillard      | Red Hat Desktop team http://redhat.com/
veillard redhat com  | libxml GNOME XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/



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