I am trying to insert some XML nodes (plus child nodes) into an XSLT transformed document. I have the XML as a string, and so at first I passed this string in and simply printed it. However, all the <s and >s were escaped as < and > and so I realized that an XML parser would ignore these and not recognize the string as XML nodes.
I tried first writing the string to a file, and then loading it up using the document() function. However, this resulted in the error: Resolving of external URIs was prohibited. I also realized that due to the sensitive nature of the documents being transformed this could pose a serious risk, as anybody could write a file with whatever they liked to that location and it would potentially be picked up and inserted into the output XML.
So, I tried passing the XML in as a URI with data:text/xml appended to it, as the document function is supposed to be able to parse and load URIs of this kind. However, this has resulted in the same error: Resolving of external URIs was prohibited.
My XslCompiledTransform object is being instantiated correctly, as far as I know. XsltSettings are set to allow the document() function to be used, and I have passed in the XmlUrlResolver object.
var xslt = new XslCompiledTransform(true);
var resolver = new XmlUrlResolver();
#if DEBUG
xslt.Load(Location, new XsltSettings(true, true), resolver);
#else
xslt.Load(XmlReader.Create(new StringReader(this.Text)), new XsltSettings(true, true), resolver);
#endif
I am at somewhat of a loss here. Really, the ideal would be to have a way to pass in the string and tell the Transformation Processor not to escape the <s and >s. Is there a way to do this?
ImportNode()being one of them. Why does it have to be XSLT?