Skip to Content.
Sympa Menu

xom-interest - Re: [XOM-interest] SAXConverter and DOMConverter

xom-interest AT lists.ibiblio.org

Subject: XOM API for Processing XML with Java

List archive

Chronological Thread  
  • From: John Cowan <jcowan AT reutershealth.com>
  • To: laurent.bihanic AT atosorigin.com (Laurent Bihanic)
  • Cc: jcowan AT reutershealth.com (John Cowan), xom-interest AT lists.ibiblio.org (Xom Interest)
  • Subject: Re: [XOM-interest] SAXConverter and DOMConverter
  • Date: Fri, 20 Sep 2002 07:37:13 -0400 (EDT)

Laurent Bihanic scripsit:

> Although most XMLReader methods could be added and mapped nicely to
> existing
> SAXConverter methods, the 2 parse() methods don't fit. They would force XOM
> to
> provide a SAXConverter-specific InputSource implementation wrapping a XOM
> document.

That is what I did when I wrote DOMParser back in SAX1 days. But SAX2
has a standard pattern for tree-walking SAX parsers: the parse() methods
ignore their parameters, and one specifies the tree object with setProperty
(String magicURI, nu.xom.Document doc).

SAX2 defines the standard property URI for the DOM tree to walk as
http://xml.org/sax/properties/dom-node, so I would think that
http://xom.nu/properties/xom-node would be a suitable URI for XOM.

Implementation note: When I wrote DOMParser, I was careful *not* to
use recursion, because there would be no guarantee that the Java stack
wouldn't blow up. Instead I used the incremental version of walking
the whole tree:

1) firstChild, unless null, in which case
2) nextSibling, unless null, in which case
3) parent() and try again, unless root, in which case
4) stop.

--
John Cowan http://www.ccil.org/~cowan jcowan AT reutershealth.com
Please leave your values | Check your assumptions. In fact,
at the front desk. | check your assumptions at the door.
--sign in Paris hotel | --Miles Vorkosigan




Archive powered by MHonArc 2.6.24.

Top of Page