Made a xslt template with output instruction for <DOCTYPE>
:
<xsl:output media-type="text/html" method="html" encoding="windows-1251" doctype-public="-//W3C//DTD XHTML 1.1//EN" doctype-system="http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd" omit-xml-declaration="yes"/>
In xsl-debug I'm receiving right
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
on top of the html.
But when I'm using XslCompiledTransform etc.. output starts from
<html xmlns="http://www.w3.org/1999/xhtml">
So, DOCTYPE is missed. Why? Right properties of XslCompiledTransform
initialized just like I set in <xsl:output>
.
Code:
using (var sw = new StringWriter())
{
XslCompiledTransform xslt = new XslCompiledTransform();
XmlEmbeddedResourceResolver resolver = new XmlEmbeddedResourceResolver();
xslt.Load("clires://DLLPATH/xsl/blank.xsl", XsltSettings.TrustedXslt, resolver);
XmlWriterSettings set = new XmlWriterSettings();
set.ConformanceLevel = ConformanceLevel.Auto;
xslt.Transform(ticket, XmlWriter.Create(sw, set));
return sw.ToString();
}
How can I get DOCTYPE from XslCompiledTransform?
您需要使用XslCompiledTransform
OutputSettings属性中的XmlWriterSettings
XmlWriterSettings set = xslt.OutputSettings;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.