I have the following VB.NET code that I am using to transform some XML into new XML, that I then continue processing. This is a one off process, not something that is done multiple times, so no efficiencies to be gained from caching, as far as I can see.
The code works, but I am seeing performance issues. I appreciate that the performance issues may be related to the XSLT.
I have also found instances of developers having performance issues with XslCompiledTransform, especially on a 64-bit environment, which may be a bug (http://connect.microsoft.com/VisualStudio/feedback/details/508748)
Neither possible XSLT performance issues nor problems with XslCompiledTransform are under my control, but it is feasible that there are problems with my code. I just want to make sure that my method of doing the transform is the most efficient method for what I need.
Public Function TransformUsingXPathNavigator(ByVal InputXML As XmlDocument, ByVal XSLTLocation As String) As XmlDocument
Dim theNavigator As XPathNavigator
theNavigator = InputXML.CreateNavigator()
Dim theTransform As XslCompiledTransform = New XslCompiledTransform()
theTransform.Load(XSLTLocation)
Dim outputXML As New XmlDocument()
Using writer As XmlWriter = outputXML.CreateNavigator().AppendChild()
theTransform.Transform(theNavigator, writer)
End Using
Return outputXML
End Function
Is anyone able to point out any problems with my code?
Edit: This is a one-off transform, so no loops.
XslCompiledTransformobject outside the loop and passing it in place ofXSLTLocation. The fewer times thatLoad()method runs, the better. - psmay