I have an XML file that already contains a reference to an XSLT file.
I'm looking at converting this XML file, according to the referenced transformation rules, so that I can then create a nice PDF file.
It appears that I can perform the actual transform via System.Xml.Xsl.XslCompiledTransform
, but it requires that I manually associate an XSLT before I perform the transform.
Based on what I've seen, I must now manually pull the XSLT reference from the XDocument (rough start below):
xmlDocument.Document.Nodes()
.Where(n => n.NodeType == System.Xml.XmlNodeType.ProcessingInstruction)
However, since the XSLT is already referenced within the XML file itself, I assume I'm doing too much work, and there's a more efficient way to apply the transform.
Is there, or is this what one has to do?
There is no more efficient way to do that. You have to retrieve href to xslt from your xml before transforming it.
Similar question here : XslTransform with xml-stylesheet
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With