Thanks Michael.

And also Mike and Andrew...

On 9/6/2013 3:45 AM, Michael Kay wrote:
The approach you are using with a SAX filter will work very well with Saxon, in fact until I got to your last paragraph that's what I assumed you were doing.

Write your code as a SAX filter, which receives events from the XMLReader and emits a modified stream of events to a ContentHandler.

There are several ways of integrating this. If you implement the XMLFilter interface (e.g. by extending XMLFilterImpl) then your class is an XMLReader and can be supplied as the XMLReader in a SAXSource passed as input to the Saxon transform() method. Alternatively, using the s9api API, you can create a DocumentBuilder, call DocumentBuilder.newBuildingContentHandler to get a SAX ContentHandler to which you can write the SAX events.

There's certainly no need to modify any Saxon internals!

Michael Kay
Saxonica


On 5 Sep 2013, at 19:38, Steve Carton wrote:

I'm using Saxon to transform (XSLT) documents that are not well formed. 
The document problems are simple to fix - they are missing final end 
tags on elements.

At the moment, I've got a bit of Java code that simply SAX parses the 
bad XML using a subclassed Reader that I wrote and which supplies the 
missing end tags after the Reader hits the end of the XML using a simple 
stack of open elements maintained in the parsers handler. The SAX parse 
emits an output stream that is the "fixed" XML, which I then use as the 
input to the Saxon XSLT transform.

What I would like to do instead is eliminate that double-parsing 
approach and somehow build whatever Saxon needs as input by way of the 
SAX parse. I looked at a revised version of TinyBuilder to do this - it 
would be similar to what I'm doing now and so, easy enough to code. I 
have two concerns with this approach. First is that I would be changing 
part of the Saxon distribution and so potentially introducing update 
issues later. Second is that I don't know if this would be a fast or 
performant approach - is this how Saxon creates a TinyTree internally?

Is there a better way?

Thanks...
-- 
Steve Carton

------------------------------------------------------------------------------
Learn the latest--Visual Studio 2012, SharePoint 2013, SQL 2012, more!
Discover the easy way to master current and previous Microsoft technologies
and advance your career. Get an incredible 1,500+ hours of step-by-step
tutorial videos with LearnDevNow. Subscribe today and save!
http://pubads.g.doubleclick.net/gampad/clk?id=58041391&iu=/4140/ostg.clktrk
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
saxon-help@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/saxon-help 

------------------------------------------------------------------------------
Learn the latest--Visual Studio 2012, SharePoint 2013, SQL 2012, more!
Discover the easy way to master current and previous Microsoft technologies
and advance your career. Get an incredible 1,500+ hours of step-by-step
tutorial videos with LearnDevNow. Subscribe today and save!
http://pubads.g.doubleclick.net/gampad/clk?id=58041391&iu=/4140/ostg.clktrk
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
saxon-help@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/saxon-help 




--
Steve