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

On Feb 6, 2006, at 1:54 PM, Wolfgang Hoschek wrote:



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.


I should add that using a data structure along the lines of nux.xio.io.NamespacesInScope instead of SAX NamespaceSupport in nu.xom.Serializer yields overall serialization speedup of about 1.5 when using namespaced docs such as nux/samples/data/wsdl-ogsi.xml, as measure by BinaryXMLTest and BinaryXMLBench (which also support non- binary modes despite their name). NamespacesInScope also performs very well for non-namespaced docs.

This is because NamespaceSupport.declarePrefix() is really yet another "agressively suboptimal" path for namespaced docs. Apparently David Megginson once mentioned the whole class was one of his 4 hour hacks... and expressed surprise that folks wanted to seriously reuse it, or generalize it even further :-)

Wolfgang.






Archive powered by MHonArc 2.6.24.

Top of Page