Skip to Content.
Sympa Menu

xom-interest - Re: [XOM-interest] Recursion

xom-interest AT lists.ibiblio.org

Subject: XOM API for Processing XML with Java

List archive

Chronological Thread  
  • From: Elliotte Rusty Harold <elharo AT metalab.unc.edu>
  • To: jcowan AT reutershealth.com
  • Cc: xom-interest AT lists.ibiblio.org
  • Subject: Re: [XOM-interest] Recursion
  • Date: Mon, 8 Mar 2004 16:16:56 -0500

At 4:06 PM -0500 3/8/04, jcowan AT reutershealth.com wrote:

This does preorder processing (parents before children). Provided there
are O(1) ways to find the first child, right sibling, and parent, this
is slightly more time-efficient than recursion, and its stack consumption
is O(1).

I think I've got it now. That O(1) is a kicker though. At the moment I don't have an O(1) means to find the right sibling. But I think I see an optimization that should make this order 1, given that I'm always iterating forward.

For processing other than from the root node, you eliminate step 0 and
change step 4 to "If the current node is not the initial node".

Yes, the first time the code compiled that bug tripped me up. Fortunately the unit tests caught it, and I was able to fix it.

One thing I'm noticing is there's a lot more recursion in the code, not just in the Serializer and toXML(). For instance, the getValue() and getNamespace(String prefix) methods are recursive. It should be easy enough to remove from getValue(). Removing it from getNamespace() will be trickier.
--

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




Archive powered by MHonArc 2.6.24.

Top of Page