xom-interest AT lists.ibiblio.org
Subject: XOM API for Processing XML with Java
List archive
- From: Wolfgang Hoschek <whoschek AT lbl.gov>
- To: Elliotte Rusty Harold <elharo AT metalab.unc.edu>
- Cc: xom-interest AT lists.ibiblio.org
- Subject: Re: [XOM-interest] DOMConverter bug
- Date: Fri, 20 Aug 2004 23:01:18 -0700
Thanks, seems to work for now...
Allow me to speculate that most of those bugs seem to be the result of the inherent obscurity of an iterative version over a recursive version. Run a diff between the current version and d25 for a case study of simplicity vs. complexity.
Why is this stuff iterative anyway? If it's because of potential stack overflows, I'd like to see a real world use case that employs documents with the incredibly deep nesting levels it takes to generate stack overflows (i.e. depth = O(25000) according to the snippet below). As far as I can see, only infinite loops produce such docs, and those are a result of bugs anyway.
I'd go for a codebase that's easy to understand and maintain (implies a good chance of being bug free) over one that tries to account for practically irrelevant, obscure failure modes (and fails for practically relevant cases). Same argument applies to other iterative tree walking XOM methods, IMHO.
BTW, a side effect of the iterative version is that it seems to exponentially slow down with increasing depth level; a behaviour not observed for the recursive versions (xom-1.0d25).
// determine at which XML nesting level the stack starts to overflow:
public static void main(String[] args) throws Exception {
int i=1;
try {
while (true) {
System.out.print(i+" ");
org.w3c.dom.Document dom = XMLUtil.xom2dom(new Document(generate(i)));
i = (i * 6) / 5 + 1;
}
} catch (StackOverflowError e) {
System.out.println("overflow at " + i);
}
System.out.println("goodbye");
}
private static Element generate(int depth) {
Element root = new Element("root");
Element curr = root;
for (int i=0; i < depth; i++) {
Element next = new Element("elem"+i);
curr.appendChild(next);
curr = next;
}
return root;
}
On Aug 20, 2004, at 7:24 PM, Elliotte Rusty Harold wrote:
The code now in CVS should fix this. Please try it out and verify that it works for you. Or if that's inconvenient, holler, and I'll send you a JAR file.
This was really a bear of a test case. It exercised five different bugs, a couple of which were very tricky to fix without breaking something else somewhere else. However, I think I've got them all stomped now. I've checked in several unit tests inspired by this example. If my fixes break anything else, it's something I don't have a unit test for, so send in any problem cases you encounter.
--
Elliotte Rusty Harold
elharo AT metalab.unc.edu
Effective XML (Addison-Wesley, 2003)
http://www.cafeconleche.org/books/effectivexml
http://www.amazon.com/exec/obidos/ISBN%3D0321150406/ref%3Dnosim/ cafeaulaitA
-
[XOM-interest] DOMConverter bug,
Wolfgang Hoschek, 08/19/2004
-
Re: [XOM-interest] DOMConverter bug,
Elliotte Rusty Harold, 08/20/2004
- Re: [XOM-interest] DOMConverter bug, Elliotte Rusty Harold, 08/20/2004
-
Re: [XOM-interest] DOMConverter bug,
Elliotte Rusty Harold, 08/20/2004
-
Re: [XOM-interest] DOMConverter bug,
Wolfgang Hoschek, 08/21/2004
-
Re: [XOM-interest] DOMConverter bug,
Elliotte Rusty Harold, 08/21/2004
- Re: [XOM-interest] DOMConverter bug, John Cowan, 08/21/2004
-
Re: [XOM-interest] DOMConverter bug,
Wolfgang Hoschek, 08/21/2004
-
[XOM-interest] XOM in an applet,
Ken Kast, 08/22/2004
-
Re: [XOM-interest] XOM in an applet,
Elliotte Rusty Harold, 08/22/2004
- Re: [XOM-interest] XOM in an applet, Ken Kast, 08/23/2004
- Re: [XOM-interest] XOM in an applet, Elliotte Rusty Harold, 08/23/2004
- Re: [XOM-interest] XOM in an applet, Elliotte Rusty Harold, 08/23/2004
-
Re: [XOM-interest] XOM in an applet,
Elliotte Rusty Harold, 08/22/2004
-
[XOM-interest] XOM in an applet,
Ken Kast, 08/22/2004
-
Re: [XOM-interest] DOMConverter bug,
Elliotte Rusty Harold, 08/21/2004
-
Re: [XOM-interest] DOMConverter bug,
Wolfgang Hoschek, 08/21/2004
-
Re: [XOM-interest] DOMConverter bug,
Elliotte Rusty Harold, 08/20/2004
Archive powered by MHonArc 2.6.24.