Skip to Content.
Sympa Menu

xom-interest - Re: [XOM-interest] Further thoughts on filters and factories

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: John Cowan <jcowan AT reutershealth.com>
  • Cc: xom-interest AT lists.ibiblio.org
  • Subject: Re: [XOM-interest] Further thoughts on filters and factories
  • Date: Thu, 17 Jul 2003 23:56:07 -0400

At 11:23 AM -0400 7/7/03, John Cowan wrote:

I've been playing with the API, and I think something John suggested
here is likely to work. First I'll rename makeElement to
beginMakeElement and endElement to finishMakeElement. (Would
beginMakingElement and finishMakingElement be more grammatical? or
perhaps startMakingElement and finishMakingElement?)

I like the last pair best. ("Start" goes with "finish", "begin" with "end").

I think I do too. Unless there's a lot of screaming, startMakingElement and finishMakingElement it is. It's a little wordy, but this is an advanced part of XOM many users won't see, and very few users will need to type this more than once. I think developers will mostly just override it, not invoke it directly.


I thought about suggesting this, but decided not to do so for the reason
you give below: the rest of the tree is unavailable. The importance
of this is that whether you want to skip a node often depends directly
on what the current context is, which is most easily discovered in the
XOM context by poking about in the tree. An obvious use case would be
deciding to discard detail elements based on the container element.

It now seems simplest to just have endElement remove the entire node on returning null. No explicit detachment will be required (or allowed). That way the parent will always be available.

You could get the best of both worlds by simply passing the presumptive
parent node as an argument to startMakingElement.

finishMakingElement will now provide parent nodes for applications that want context via element.getParent(). I wonder, though, if I should pass parent nodes to everything; i.e what's the parent of this comment? this text? My gut is no, it shouldn't It makes the class too complex, especially for its original use-case of selecting different subclasses of the core XOM classes. If somebody really wants that extra context, they can store a stack of parent nodes in the factory as they're created.
--

Elliotte Rusty Harold
elharo AT metalab.unc.edu
Processing XML with Java (Addison-Wesley, 2002)
http://www.cafeconleche.org/books/xmljava
http://www.amazon.com/exec/obidos/ISBN%3D0201771861/cafeaulaitA




Archive powered by MHonArc 2.6.24.

Top of Page