xom-interest AT lists.ibiblio.org
Subject: XOM API for Processing XML with Java
List archive
- From: Hallvard Trætteberg <hal AT idi.ntnu.no>
- To: <xom-interest AT lists.ibiblio.org>
- Subject: [XOM-interest] XPath and Id handling for XOM
- Date: Thu, 25 Sep 2003 11:44:26 +0200
Hi,
One of the reasons I have not used XOM much is its lack of support for
XPath (with Jaxen) and handling of special handling ID attributes.
Nevertheless, XOM has many nice features so I decided to contribute
these two things. I have
- extended Jaxen with a DocumentNavigator for XOM (1.0d21) that passes
all of Jaxen's test. I essentially ported JDOM's navigator.
- implemented an IdDocument class, a Document that tracks changes that
affect the set of ID attributes (based on recent additions to the xom
api), still som junit test need to be written
Now comes the question of how to include this into XOM, i.e. how to
access a(ny) xpath implementation from xom (ala the xslt support) and
what kind of contrib package structure the id stuff may be put in.
I also have a suggestion regarding Element's implementation of
Node.getValue(). It currently accumulates the childs' values in a
StringBuffer. In many cases there is only one child, and this could be
handled as a special case (for speed and reduced memory consumption), as
follows:
if (getChildCount() == 1) {
Node child = getChild(0);
if (child.isText() || child.isElement()) {
return child.getValue();
}
}
StringBuffer result = new StringBuffer();
for (int i = 0; i < getChildCount(); i++) {
...
}
return result.toString();
}
Of course, this complicates the code and may not increase the speed
much. However, the code is still fairly obvious, so why not?
Hallvard
---
Hallvard Trætteberg, 1.amanuensis ved Inst. for datateknikk og
informasjonsvitenskap ved NTNU
www.idi.ntnu.no/~hal, mailto:hal AT idi.ntnu.no phone:+47 7359 3443,
-
[XOM-interest] XPath and Id handling for XOM,
Hallvard Trætteberg, 09/25/2003
- [XOM-interest] Possible optimization for getValue(), Elliotte Rusty Harold, 09/25/2003
- Re: [XOM-interest] XPath and Id handling for XOM, Elliotte Rusty Harold, 09/25/2003
- Re: [XOM-interest] XPath and Id handling for XOM, Elliotte Rusty Harold, 09/25/2003
Archive powered by MHonArc 2.6.24.