[
Lists Home |
Date Index |
Thread Index
]
Elliotte Rusty Harold wrote:
> Question: should the the transformer fire startDocument() and
> endDocument() events? even though this isn't a complete document, only a
> document fragment?
>
> The SAX API doc is not absolutely clear on this point. However, my
> interpretation is that yes, it should call startDocument() and
> endDocument().
This might not be the answer you want to hear, but while I am loathe to add new
methods I think that the cleanest way to do this would be to add
startDocumentFragment() and endDocumentFragment(), and bump up the SAX rev. The
default implementation might throw an exception on these. It could be
conditioned to a feature defaulting to false.
The reasons for this are that:
- ContentHandlers are entitled to believe that a document has only one
beginning and one end, and that a document has only one root element. Defining
behaviour post-hoc is likely to lead to breakage.
- it may lead to intersting mappings with the DOM.
- it would have other uses, such as signaling the fact that a fragment is
being merged into a larger stream (ie it could be possible to use
startDocumentFragment() in the middle of a stream -- again probably conditionned
to the truthing of a feature). This might be because of an XInclude, or because
of any other merging technique (eg the kind that is possible using
XML::SAX::Machines). Such an event was already required by the PerlSAX community
because it would be interesting to have specific behaviour within included
fragments, for instance to deal with locally useful namespace normalisation.
--
Robin Berjon <robin.berjon@expway.fr>
Research Engineer, Expway
7FC0 6F5F D864 EFB8 08CE 8E74 58E6 D5DB 4889 2488
|