xom-interest AT lists.ibiblio.org
Subject: XOM API for Processing XML with Java
List archive
- 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.
-
Re: [XOM-interest] uuid generation (was Re: Scope of namespaces)
, (continued)
-
Re: [XOM-interest] uuid generation (was Re: Scope of namespaces),
Nils Kilden-Pedersen, 02/07/2006
- Re: [XOM-interest] uuid generation (was Re: Scope of namespaces), Wolfgang Hoschek, 02/07/2006
- Re: [XOM-interest] uuid generation (was Re: Scope of namespaces), Steve Loughran, 02/07/2006
- Re: [XOM-interest] uuid generation (was Re: Scope of namespaces), Tatu Saloranta, 02/07/2006
- Re: [XOM-interest] uuid generation (was Re: Scope of namespaces), Wolfgang Hoschek, 02/07/2006
- Re: [XOM-interest] uuid generation (was Re: Scope of namespaces), Wolfgang Hoschek, 02/07/2006
-
Re: [XOM-interest] uuid generation (was Re: Scope of namespaces),
Nils Kilden-Pedersen, 02/07/2006
- Re: [XOM-interest] Scope of namespaces, Wolfgang Hoschek, 02/06/2006
- Re: [XOM-interest] Scope of namespaces, Elliotte Harold, 02/07/2006
- Re: [XOM-interest] Scope of namespaces, Michael Kay, 02/06/2006
Archive powered by MHonArc 2.6.24.