Question

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.

Was it helpful?

Solution

We were never able to improve the efficiency of the code using XslCompiledTransform.

We were able to identify loops within the XSLT that were running many times, and when removed the code went from taking 60+ seconds to less than 1 second.

However, the XSLT was out of my control and so I needed to find an alternative solution. It was not ideal, but I had to go back to the obsolete XslTransform.

Using XslTransform the code runs in less than 1 second, which is what I need.

Going forward the XSLT we use will need to be sorted out, but for now using obsolete code is the solution to my problem.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top