Saxon's identity transform could be made faster for cases like Sax->Sax by bypassing the conversion from SAX events to Saxon's internal Receiver events and back again; but that would be optimizing a rather unusual special case. For StreamResult and DOMResult Saxon's identity transform is reusing the backend code designed primarily for XSLT transforms, which expects to take the output stream in the form of Receiver events.
Although Saxon implements the IdentityTransformer interface, I've never made any attempt to make the implementation better or faster than the one that comes for free in the JDK, and the SAX-to-SAX case certainly doesn't seem an important enough use case to justify optimizing. 


Michael Kay

From: Erik Vanherck []
Sent: 09 March 2010 14:33
Subject: [saxon] Identity transform performance



I was toying around with parser performance on a 10mb XML file I need to transform later on in large volumes; to select the best method of processing when I came across the following numbers. My destination was in each of the cases a nop sax handler :


SAX JDK 1.6 (Xerces fork) : 280 ms

SAX Fastinfoset parser : 29 ms

SAX Fastinfoset parser -> Saxon Identity Transform : 186ms

SAX Fastinfoset parser -> JDK 1.6 Transfomer (Xalan XSLTC fork) Identity Transform :  120ms


Don’t mind the numbers itself, although properly executed with the server jvm in a loop it was on a simple box and other stuff was running. It’s the relative difference that I’m interested in.


Quite happy by the fast infoset numbers, I was adding stuff to just build up my pipeline. But what took me by surprise was the overhead the identity transform added. I verified a possible bogus construct by trying out the JDK’s transformer instead of Saxon and although it performed better it still adds some significant time. My assumption was that a such a transformation takes very little effort as it’s a popular (if not the defacto) way to get from SAX to DOM or vice versa, but obviously I was wrong. Can anyone offer an insight on what might be the cause ?


With kind regards,


Erik Vanherck

Product Delivery Manager


Phone: +32 3 821 01 70

Office Fax: +32 3 821 01 71


Inventive Designers' Email Disclaimer:

This message has been scanned for viruses and
dangerous content, and is believed to be clean.