xom-interest AT lists.ibiblio.org
Subject: XOM API for Processing XML with Java
List archive
Re: [XOM-interest] Further thoughts on filters and factories
- From: John Cowan <jcowan AT reutershealth.com>
- To: Elliotte Rusty Harold <elharo AT metalab.unc.edu>
- Cc: xom-interest AT lists.ibiblio.org
- Subject: Re: [XOM-interest] Further thoughts on filters and factories
- Date: Mon, 7 Jul 2003 11:23:50 -0400
Elliotte Rusty Harold scripsit:
> At 9:38 AM -0400 6/18/03, John Cowan wrote:
>
> >This is a classic datahead/dochead split, and the fact that you're
> >ambivalent shows that you have some of each in your makeup. :-)
> >Dataheads think of an element as a container for its content, and
> >if the container is removed, the content goes to Tumbolia with it.
> >Docheads think of elements as basically annotations of ranges, and if
> >the annotation is removed, the underlying content remains.
> >
> >I don't think you can make everyone happy here. Just make sure that
> >*some* path through the code makes it possible to do either operation.
>
>
> 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").
> Next, I'll move the actual attachment to the tree in XOMHandler into
> endElement instead of startElement. The element node will only be
> attached to the tree if finishMakeElement returns non-null. Thus
> returning null from beginMakeElement will remove the start-tag and
> end-tag, while leaving the contents intact. Returning null from
> finishMakeElement will remove the entire element including its
> contents. This is a more consistent API with no need to call detach.
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.
You could get the best of both worlds by simply passing the presumptive
parent node as an argument to startMakingElement.
--
John Cowan www.ccil.org/~cowan www.reutershealth.com
jcowan AT reutershealth.com
In might the Feanorians / that swore the unforgotten oath
brought war into Arvernien / with burning and with broken troth.
and Elwing from her fastness dim / then cast her in the waters wide,
but like a mew was swiftly borne, / uplifted o'er the roaring tide.
--the Earendillinwe
-
[XOM-interest] Further thoughts on filters and factories,
Elliotte Rusty Harold, 07/07/2003
- Re: [XOM-interest] Further thoughts on filters and factories, Bradley S. Huffman, 07/07/2003
-
Re: [XOM-interest] Further thoughts on filters and factories,
John Cowan, 07/07/2003
- Re: [XOM-interest] Further thoughts on filters and factories, Elliotte Rusty Harold, 07/18/2003
Archive powered by MHonArc 2.6.24.