> > Hello,
> > I'm performing a sequence of transforms on a single source document in
> > a xalan pipeline using SAXsource and SAXresult. To make the pipeline
> > more intelligent I'd like to peek in the source DOM (if there's one?)
> > to see which transforms in the pipeline need be executed. My question
> > is in xalan is a DOM tree created by an XMLReader or other part of the
> > process or do I have to set up my own DOM tree to query as in the
> > ApplyXPath and ApplyXPathDOM examples. Any enlightenment is greatly
> > appreciated.
> 

I'm no expert, but here's my view:

-- input

You have a choice of feeding Xalan with a stream of sax events
(SAXSource), passing it a DOM (DOMSource) or passing it an input stream
(StreamSource, eg file or in-memory string). 

If you pass a DOM as the source, then Xalan uses it (via a thin API
wrapper internally, called DTMToDOM or something similar).

If you pass Xalan a sax event stream, then Xalan builds an in-memory
representation of the input (a special kind of DOM called a DTM which is
more efficient than a DOM, so choose this approach if you can).

If you pass Xalan a StreamSource, it just creates a SAX parser object
internally, and then acts as if you had passed it a SAXSource, being the
parser. This just saves you a few lines of code; it is the same as if
you had created the SAXParser object yourself, used it to parse the
input, and sent the sax events to Xalan.


-- output

Whatever means you use to pass the input to Xalan, for its output Xalan
always passes SAX events to whatever Result object you specified for the
transform.

It is up to whatever Result object you passed to the transform as to
what to do with the sax events generated as the result of the transform:
(a) a DOMResult builds a DOM from the events
(b) a serializer can write straight to a string/file/etc
(c) the events can be passed straight into another transformer
    (pipeline), in which case the *receiving transform* builds a DTM
    internally to represent the input, then generates SAX events....

-- 

So if you want to peek at the very original input to Xalan, then fine:
build a DOM using Xerces or similar, make your decisions about what
transforms will exist in your pipeline, set up your pipeline, then pass
the DOM (wrapped in a DOMSource object) to the first transformer to
kick-start it all.

However if you want to peek at the output of the first transform to
decide which transform to run second, you will need to store the output
from the first transform in a DOM (using DOMResult), make your decision,
then pass that DOM to the second transform.




I hope this was the info you were looking for....

Cheers,

Simon


Reply via email to