W3C home > Mailing lists > Public > www-dom@w3.org > January to March 2007

Re: XPathNSResolver doubts

From: Bjoern Hoehrmann <derhoermi@gmx.net>
Date: Tue, 30 Jan 2007 03:45:00 +0100
To: Joćo Eiras <joao.eiras@gmail.com>
Cc: www-dom@w3.org
Message-ID: <lebtr2587jvbt4njrrrc8r48jl7uk70aug@hive.bjoern.hoehrmann.de>

* Joćo Eiras wrote:
>Is a XPathNSResolver returned from createNSResolver be live or static ?

As the Working Group Note says, "using the current information available
in the node's hierarchy at the time lookupNamespaceURI is called." It is
live. As for your test case, see below.

>Which uri should a XPathNSResolver return if there are 2 nodes in the dom  
>tree with different uri but equal prefix ?

This question does not arise, in a specific context a prefix can only
map to zero or one namespace names. In case of createNSResolver(...),
the resolver works pretty much as if calling Node.lookupNamespaceURI
which only looks at the current node and its ancestors. No attempt is
made to search descendants or siblings for namespace declarations. The
main use case for this feature is if you have e.g. an

  <xsl:template xmlns:p='...'
    <xsl:value-of select='p:example' ...

and want to evaluate the expression. Here you can adapt to the value-
of element and use its in-scope namespace prefixes. As per the Name-
spaces in XML Recommendations, at most one mapping can be in scope.

If you want to search the whole document for namespace declarations and
use those to resolve prefixes, you could walk the whole tree to collect
them, or query the XPath namespace:: axis to the same effect, if that
works properly in your implementation.
Björn Höhrmann · mailto:bjoern@hoehrmann.de · http://bjoern.hoehrmann.de
Weinh. Str. 22 · Telefon: +49(0)621/4309674 · http://www.bjoernsworld.de
68309 Mannheim · PGP Pub. KeyID: 0xA4357E78 · http://www.websitedev.de/ 
Received on Tuesday, 30 January 2007 02:45:08 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 20 October 2015 10:46:13 UTC