Is there a more efficient way to convert an XDocument that already contains a link to XSLT?

I have an XML file that already contains a link to an XSLT file.

I am looking to convert this XML file according to the specified conversion rules, so that I can then create a good PDF file.

It looks like I can do the actual conversion through System.Xml.Xsl.XslCompiledTransform, but for this I have to manually bind XSLT before doing the conversion.

Based on what I saw, now I have to manually pull the XSLT link from the XDocument (rough start below):

xmlDocument.Document.Nodes()
   .Where(n => n.NodeType == System.Xml.XmlNodeType.ProcessingInstruction)

However, since XSLT is already mentioned in the XML file itself, I assume that I am doing too much work, and there is a more efficient way to apply the conversion.

Is there, or is this what you need to do?

+5
source share
1 answer

There is no more efficient way to do this. You must return href to xslt from your xml before converting it.

A similar question here: XslTransform with xml-stylesheet

+1
source

All Articles