Skip to Content.
Sympa Menu

xom-interest - Re: [XOM-interest] Scope of namespaces

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: Elliotte Harold <elharo AT metalab.unc.edu>
  • Cc: xom-interest <xom-interest AT lists.ibiblio.org>
  • Subject: Re: [XOM-interest] Scope of namespaces
  • Date: Mon, 6 Feb 2006 13:54:46 -0800



You can get a list of the namespaces in scope on an element using an
XPath query such as

Nodes namespaces = element.query("namespace::node()");

This still ascends the tree, but at least you don't have to write your
own code for doing so.

I've written a simple benchmark to see just how bad the various methods
for iterating over namespaces really are.

https://xom.dev.java.net/source/browse/xom/src/nu/xom/benchmarks/ NamespaceLister.java?rev=1.1&view=markup

I'm not finished yet, but so far I'm not sure there's a practical
problem here. In my tests against http://www.rddl.org/ this code is able
to retrieve each and every namespace URI, both in scope and declared,
for every element in the document in between .1 and .3 seconds. No
caching is done. i.e. each element is treated independently of the
others. Thus the time to retrieve namespaces declared or in scope for
just one element would be a small fraction of that.

That doc is 50KB small, right? If so, that would mean about 500KB/s throughput - unusable from my point of view by about 2 orders of magnitude for non-XOM-core serialization algorithms related to XPath, XQuery, STAX, bnux, etc., as those need to iterate over the declared namespaces. I certainly wouldn't use anything like that.

Also note that element.query("namespace::node()") is inefficient for reasons that have nothing to do with namespace iteration, but rather with XPath setup.

Wolfgang.





Archive powered by MHonArc 2.6.24.

Top of Page