[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Would SAX event handlers be more cooperative?

  • From: Michal Mosiewicz <mimo@i...>
  • To: xml-dev@x...
  • Date: Wed, 17 May 2000 01:22:45 +0200

sax event handler
I discussed it on apache-xml, but here seems to be a better place.

My question is if it would be nice, if SAX event handlers returned some
informations. Currently the events are only passed in a single
direction, i.e. a sax event producer passes them to content handler, but
it is not aware about how they are passed through the line of
transformations and serializers.

I would propose that ContentHandler.startTag() would return a value
indicating, if the contentHandler is "interested" in receiving the
following content of the tag. It would possibly return values like
CONTENT_OK and CONTENT_SKIP.

That would result, that a producer using this extended information would
look like this:

if( contentHandler.startTag(...) == CONTENT_OK ) {
    //contained events produced here
}
contentHandler.endTag()

Instead of:

contentHandler.startTag(..);
//contained events
contentHandler.endTag(...);

It has interesting implication. It allows for writing better optimised
application. For example - if due to some transformations, some
informations is never used from the source document, the producer
doesn't have to supply it possibly ommiting portions of the code that is
expensive to process. If the stylesheet is able to detect that some
element is not passed any further, it returns CONTENT_SKIP, so the
producer doesn't have to waste time for unnecessary transformations.

It also allows for building fine grained caching capabilities, like
saving preserialized content in the serializer, which is able to notify
all the producers along the line, that it uses this preserialized
content, so the content producer don't have to use any processor cycles
to provide it.

If the assumption is made, that these return values are taken more as
hints than a rule to follow, it could be probably implemented not to
interfere with existing code.

Comments?

-- Mike

***************************************************************************
This is xml-dev, the mailing list for XML developers.
To unsubscribe, mailto:majordomo@x...&BODY=unsubscribe%20xml-dev
List archives are available at http://xml.org/archives/xml-dev/
***************************************************************************

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.