cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kay Michael <Michael....@icl.com>
Subject RE: SAT API Proposal (Draft 3) (was XSLT API)
Date Thu, 10 Feb 2000 12:55:35 GMT
SAX2 / ContentHandlers etc

It would be useful to add an example that uses StylesheetHandler; I can't
quite see how it's supposed to work. And if this is for feeding the
Stylesheet as a SAX event stream, what is the equivalent for source
documents?

I'm confused by your chaining example,
    transform3.setContentHandler(serializer.asContentHandler());
    transform2.setParent(transform3);
    transform1.setParent(transform2);
    transform1.parse(new InputSource("foo.xml"));

x.setParent(y) means that x takes its input from y; this is a pull model; so
my first instinct (assuming you want the sequence to be 1, 2, 3) is to
reverse it to:

    transform3.setContentHandler(serializer.asContentHandler());
    transform3.setParent(transform2);
    transform2.setParent(transform1);
    transform3.parse(new InputSource("foo.xml"));

But this seems strange, and is especially strange if the first thing in the
pipeline is not a real parser, but an application trying to supply SAX
events. It also doesn't extend to multiple outputs from a stylesheet. We
really want a "push" pipeline, whereas XMLFilter gives us a "pull" model.
Since we're doing a "push" into the serializer, perhaps we should use the
same mechanism to push events from one transformation into the next, and
from the user's application into the first transformation:

    transform3.setContentHandler(serializer.asContentHandler());
    transform2.setContentHandler(transform3);
    transform1.setContentHandler(transform2);
    application.setContentHandler(transform1);
    application.run();

That then raises the question about whether a ContentHandler is good enough,
what about events like comments that a ContentHandler doesn't handle? My
view would be to define a SATEventHandler interface that extends
ContentHandler, DTDHandler, and LexicalHandler, and to define SATFilter
modeled on XMLFilter but (a) extending SATEventHandler instead of the native
SAX2 handler interfaces, and (b) working on a push model rather than pull.

Finally, the remark about multiple outputs raises the question as to whether
setContentHandler() really belongs on Transformation at all. We already have
it on Result, which seems a more natural place: presumably there will be one
Result for each output tree, once multiple outputs are in the XSLT spec.

Mike Kay

Mime
View raw message