XslCompiledTransform eats my DOCTYPE

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?

Answers


You need to use the XmlWriterSettings from the OutputSettings property in XslCompiledTransform

XmlWriterSettings set = xslt.OutputSettings;

Need Your Help

Parsing HTML table with LXML in Python

python parsing lxml

I need to parse html table of the following structure:

How do I dynamically create jQuery ui tabs based on a certain condition?

jquery jquery-ui

I am dynamically creating tabs with jquery-ui tab component based on a passed in object called children(This functionality if apart of a much larger application).

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.