My suggestion is that StAX is best for this.
You can simply stop reading when you get to where you want it and you wont get any exceptions,
the parser only reads far enough to satisfy the next read request.
David A. Lee
----- Original Message -----
From: Todd Gochenour
To: Mailing list for the SAXON XSLT and XQuery processor
Sent: Saturday, April 11, 2009 11:58 AM
Subject: Re: [saxon] Using both Saxon and Xalan

How wasteful is a SAX process that terminates after reading the root element node?  It opens the file and reads the root element and its attributes and then closes the file.  Is that an expensive operation?
The namespace problem presented itself as "stylesheet requires attribute: version" when in fact the file had a version.  It took a day of research to figure out that the factory needed a boolean flag set to true for this to work.  Not at all intuitive.
When I got to the I/O exception when passing the DOMSource to the transformer I lost interest in the approach.  It wasn't til after the SAX strategy was finished that I came to realize the base URI isn't set for a DOMSource like it is automatically with a StreamSource.
I'm an XSL programmer more than a Java programmer.  I don't have  much patience dealing with object oriented plumbing issues like this.  Document centric functional programming is so much easier for me.

This email is sponsored by:
High Quality Requirements in a Collaborative Environment.
Download a free trial of Rational Requirements Composer Now!

saxon-help mailing list archived at