Friday, 15 February 2013

c# - Optimising XDocument to XDocument XSLT -


Text after "

The following code works but is messy and slow. I am using XSLT2 with Saxon to replace an XDocument for another XDocument, optimized using SaxonWrapper:

  public static XDocument HSRTransform (XDocument source) {System.Reflection.Assembly thisExe = System.Reflection.Assembly.GetExecutingAssembly (); System.IO.Stream xslfile = thisExe.GetManifestResourceStream ("C2KDataTransform.Resources.hsr.xsl"); XmlDocument xslDoc = New XmlDocument (); XslDoc.Load (xslfile); XmlDocument sourceDoc = New XmlDocument (); SourceDoc.Load (source.CreateReader ()); Var sw = new stringwriter (); Xls2 processor processor = new xsl2 processor (); Processor.load (xslDoc); Processor.Transform (sourceDoc, new XmlTextWriter (sw)); XDocument outputDoc = XDocument.Parse (sw.ToString ()); Return output dock; }  

I realize that the slow speed can actually be in bits, I have no control, but what better way to make all the changes between XDocument and XmlDocument and the use of authors is?

>

>

  XDocument outputDoc = new XDocument (); Processor.Transform (sourceDoc, outputDoc.CreateWriter ()); Return output dock; Apart from this, other recessions may be in succession and instead of using the old XmlDocument - instead of the fast cousin. 


No comments:

Post a Comment