Search code examples
xmlwebconfigurationxslt-1.0xslt-2.0

Not able to load xml/config file into my xslt file


I'm trying to consume the configuration values from external xml file into my XSLT file.

<xsl:apply-templates select="document("\test\test.xml")/> Error: Execution of the document function prohibited

Use the XslSettings.EnableDocumentFunction property to enable it. Can anyone help me on this? how to load xml values into my xslt so that i can dynamically use them.


Solution

  • That sounds as if you use XSLT 1.0 with Microsoft's XslCompiledTransform, as the message tells you use XsltSettings with EnableDocumentFunction set to true e.g. var xsltProcessor = new XslCompiledTransform(); xsltProcessor.Load("sheet1.xsl", new XsltSettings(true, false), new XmlUrlResolver());.