Saxon is typically 4-10 times faster if it uses its own native tree model, when compared with using a DOM. Passing the XML as a string to be parsed on the Java side is the best approach.

You're right that in this environment, serializing the document and then reparsing it in order to cross the PHP/Java boundary is a a significant cost. It may take longer than the actual transformation. But it's a price you have to pay; there's no obvious way of avoiding it.

Michael Kay

On 23/12/2010 16:48, John McGowan wrote:

I'm using the Saxon XSLT processor in my PHP based content management system.  I've got everything running nicely using the PHP/Java bridge.  I've got some free time during the holidays so I'm trying to come up with ways of squeezing more performance out of my setup, and I've been thinking of how the data goes from a PHP to Java to be transformed and then back to PHP.  Basically it goes like this.

PHP has either a PHP DomDocument instance or a basic string with some XML.  Either way, I send an XML string over to the java side of things and create a StreamSource and do the saxon transform on that.

If my source document is a PHP DomDocument instance, I could recurse through the DOM in PHP and build a mirror DOM over on the java side through the bridge and then use a DomSource instead with the transformation.

My main concern is all the extra serialization/unserialization that occurs when we go from dom to string and back and forth, etc, so...

I guess the main question is whether or not the saxon transform is happier/faster if it gets a DOMSource instead of a StreamSource?  How about the other classes that Implemet Source?  Is another one a better starting point for the saxon transform process?

I'm assuming that if you pass it a stream it has to parse and turn it into a data structure, but I wanted to ask around to make sure. 

John McGowan

------------------------------------------------------------------------------ Learn how Oracle Real Application Clusters (RAC) One Node allows customers to consolidate database storage, standardize their database environment, and, should the need arise, upgrade to a full multi-node Oracle RAC database without downtime or disruption
_______________________________________________ saxon-help mailing list archived at