Skip to Content.
Sympa Menu

xom-interest - Re: [XOM-interest] adding NamespaceContext.getNamespaces()

xom-interest AT lists.ibiblio.org

Subject: XOM API for Processing XML with Java

List archive

Chronological Thread  
  • From: Wolfgang Hoschek <wolfgang.hoschek AT mac.com>
  • To: Michael Kay <mike AT saxonica.com>
  • Cc: 'Elliotte Harold' <elharo AT metalab.unc.edu>, 'xom-interest' <xom-interest AT lists.ibiblio.org>
  • Subject: Re: [XOM-interest] adding NamespaceContext.getNamespaces()
  • Date: Tue, 31 Oct 2006 11:58:48 -0800

Thanks for the background, Mike.

Wolfgang.

On Oct 31, 2006, at 11:12 AM, Michael Kay wrote:

The way the saxon binding works is to predeclare
all ns declarations on XQuery setup, rather than via a
lookup(String) callback, as in Jaxen or JAXP. That's why I'd
need something like
getNamespaces() rather than lookup(String).

The main reason Saxon needs access to all the in-scope namespaces, rather
than just a prefix-to-uri lookup method, is so that it can compile code to
do the prefix-to-uri mapping at run-time, without retaining references to
compile-time objects. There are only two constructs in standard XQuery that
need the mapping at run-time, namely computed element and attribute
constructors, but there are a lot more in XSLT and of course Saxon uses the
same mechanisms; there are also extensions such as saxon:evaluate() that use
the namespace context dynamically.

Saxon's StaticQueryContext does in fact have a
setExternalNamespaceResolver() method, which will be used to look up any
namespace prefixes that have not been actively declared: but looking at the
code I'm not sure that it currently supports these run-time uses of
namespace prefixes. And in any case the NamespaceResolver interface itself
has an iteratePrefixes() method which doesn't map onto anything in XOM's
XPathContext.

(If you want to see a really badly designed interface, look at JAXP's
javax.xml.namespace.NamespaceContext which for some weird reason allows you
to iterate over all the prefixes bound to a particular URI, but doesn't
allow you to get all the in-scope prefixes!)

Michael Kay







Archive powered by MHonArc 2.6.24.

Top of Page