Re: [xsl] Saxon .Net API performance

Subject: Re: [xsl] Saxon .Net API performance
From: Michael Kay <mike@xxxxxxxxxxxx>
Date: Wed, 01 Sep 2010 23:57:23 +0100
On 01/09/2010 5:49 PM, Merrilees, David wrote:
Thanks Michael, that's really helpful. However, I don't understand how Tinytree is used by the Saxon API in .Net.

A Tinytree will be used (a) if you let Saxon build the tree (by supplying input as unparsed lexical XML or as a SAX event stream), or (b) if you build the tree using Saxon interfaces, such as the Saxon.Api DocumentBuilder.
I'm using a .Net XmlTextWriter to serialize my objects to XML which are then built into an XdmNode (see code excerpt below), which is used as the input for transformation. As I understand, using the XmlTextWriter avoids using DOM. Does this use Saxon's tree model efficiently?

This code is constructing a TinyTree, but arguably the cost of building it could be reduced, if rather than seriallzing the "object" to lexical XML and then reparsing the lexical XML, the two stages communicated at the level of a stream of SAX-like events. But I would need to know more about where the XML is coming from to make that concept more concrete.


I've seen many applications where the serializing and reparsing that goes on between stages in the processing pipeline takes far longer than the actual transformation steps.

Michael Kay
Saxonica
public XdmNode ReadObject(object objectToSerialize, Uri baseUri) {
             XdmNode result;

             using (MemoryStream stream = new MemoryStream())
          {
         XmlSerializer xmlSerializer = new XmlSerializer(objectToSerialize.GetType());
                 using (XmlTextWriter xmlWriter = new XmlTextWriter(stream, Encoding.UTF8))
                 {
                     xmlSerializer.Serialize(xmlWriter, objectToSerialize);

                     DocumentBuilder builder = XsltHelper.Processor.NewDocumentBuilder();
                     builder.BaseUri = baseUri;

                     stream.Seek(0, SeekOrigin.Begin);
                     result = builder.Build(stream);
                 }
            }
             return result;
}

-----Original Message-----
From: Michael Kay [mailto:mike@xxxxxxxxxxxx]
Sent: 31 August 2010 21:45
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re: [xsl] Saxon .Net API performance

That's a very broad question!

I think probably the most important advice is to use Saxon's native tree model rather than running over the Microsoft DOM (which is possible, but slow). Most of the other things one can say are pretty generic, applying equally to any XSLT processor.



This is a confidential email. Tesco may monitor and record all emails. The views expressed in this email are those of the sender and not Tesco.

Tesco Stores Limited
Company Number: 519500
Registered in England
Registered Office: Tesco House, Delamare Road, Cheshunt, Hertfordshire EN8 9SL
VAT Registration Number: GB 220 4302 31

Current Thread