I am using Saxon to perform XSLT transform in .Net application. This is my .net code
private void xsltTransform()
{
string xsltFile = Path.Combine(TEirPath, "test.xsl");
string outputFile = Path.Combine(TEirPath, "test.html");
var xslt = new FileInfo(xsltFile);
var processor = new Processor();
var xsltCompiler = processor.NewXsltCompiler();
var xsltExecutable = xsltCompiler.Compile(new Uri(xslt.FullName));
var destination = new DomDestination();
var xsltTransformer = xsltExecutable.Load();
xsltTransformer.InitialTemplate = new QName("startTemplate");
xsltTransformer.Run(destination);
destination.XmlDocument.Save(outputFile);
}
And this is my sample test.xsl
<xsl:stylesheet version ="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xhtml" encoding="UTF-8"/>
<xsl:template name="startTemplate" >
<a>
<xsl:text disable-output-escaping="no">Test1 < > Test1</xsl:text>
<br/>
<xsl:text disable-output-escaping="yes">Test2 < > Test2</xsl:text>
</a>
</xsl:template>
</xsl:stylesheet>
I need to have the output to display special characters (<>) in both escaped and non-escaped forms. But from the above xsl sample, the result that i get in test.html is always escaped. I think the problem is with the Destination being output as XmlDocument, but i don't know how to get around it. Could someone give me suggestion? Thank you in advance.
saxon9he.jarand the output is as expected:<a>Test1 < > Test1 <br></br>Test2 < > Test2. If you really want to disregarddisable-output-escapingyou have to use a browser like Firefox, because they still haven't implemented it ;-)System.Xml.XmlDocumentas the transformation result? If you want doe to have any effect then I think you need to use saxonica.com/html/documentation/dotnetdoc/Saxon/Api/… over a Stream or TextWriter. But no such result like<a>test < > test <a/>can later be loaded byXmlDocumentas it is meant to parse XML and an unescaped less than sign is not XML.