xom-interest AT lists.ibiblio.org
Subject: XOM API for Processing XML with Java
List archive
- From: Elliotte Harold <elharo AT metalab.unc.edu>
- To: peter murray-rust <pm286 AT cam.ac.uk>
- Cc: xom-interest <xom-interest AT lists.ibiblio.org>
- Subject: Re: [XOM-interest] Scope of namespaces
- Date: Mon, 06 Feb 2006 08:13:00 -0500
peter murray-rust wrote:
Personally as a user of XOM I would find it much easier if all namespaces were easily available in all their descendant elements.
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.
I have not yet profiled this benchmark, so it's still possible that it's spending most of its time in something irrelevant like System.out.println(). However I think it does set a fairly low upper bound on the amount of time it takes to retrieve all namespaces declared or in scope, despite the aggressively suboptimal implementation.
There are definitely some optimizations I could make to getNamespacePrefix(int) and related methods. So far though it's not obvious this is worth doing. In practice, I suspect parsing, serializing, or simple I/O is likely to swamp any improvements I make in this method. Is anyone's code actually spending enough time here that this becomes the hot spot?
--
Elliotte Rusty Harold elharo AT metalab.unc.edu
XML in a Nutshell 3rd Edition Just Published!
http://www.cafeconleche.org/books/xian3/
http://www.amazon.com/exec/obidos/ISBN=0596007647/cafeaulaitA/ref=nosim
-
Re: [XOM-interest] Scope of namespaces
, (continued)
-
Re: [XOM-interest] Scope of namespaces,
Elliotte Harold, 02/05/2006
- Re: [XOM-interest] Scope of namespaces, Michael Kay, 02/06/2006
-
Re: [XOM-interest] Scope of namespaces,
Elliotte Harold, 02/05/2006
-
Re: [XOM-interest] Scope of namespaces,
Michael Kay, 02/06/2006
- Re: [XOM-interest] Scope of namespaces, Elliotte Harold, 02/06/2006
- Re: [XOM-interest] Scope of namespaces, Elliotte Harold, 02/06/2006
- Re: [XOM-interest] Scope of namespaces, Steve Loughran, 02/06/2006
-
Re: [XOM-interest] Scope of namespaces,
Michael Kay, 02/06/2006
-
Re: [XOM-interest] Scope of namespaces,
Steve Loughran, 02/06/2006
- Re: [XOM-interest] Scope of namespaces, Elliotte Harold, 02/06/2006
- Re: [XOM-interest] Scope of namespaces, Elliotte Harold, 02/06/2006
-
Re: [XOM-interest] Scope of namespaces,
Elliotte Harold, 02/06/2006
-
Re: [XOM-interest] Scope of namespaces,
peter murray-rust, 02/06/2006
-
Re: [XOM-interest] Scope of namespaces,
Steve Loughran, 02/06/2006
- Re: [XOM-interest] Scope of namespaces, Ed Davies, 02/06/2006
-
[XOM-interest] uuid generation (was Re: Scope of namespaces),
Tatu Saloranta, 02/06/2006
-
Re: [XOM-interest] uuid generation (was Re: Scope of namespaces),
Steve Loughran, 02/07/2006
- Re: [XOM-interest] uuid generation (OT), Tatu Saloranta, 02/07/2006
-
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),
Steve Loughran, 02/07/2006
-
Re: [XOM-interest] Scope of namespaces,
Steve Loughran, 02/06/2006
-
Re: [XOM-interest] Scope of namespaces,
peter murray-rust, 02/06/2006
-
Re: [XOM-interest] Scope of namespaces,
Elliotte Harold, 02/05/2006
Archive powered by MHonArc 2.6.24.