我将 XSLT 与 C# 结合使用,将我的 xml 文档转换为 HTML。我需要 DOCTYPE 在 HTML 文档中。但不知何故,我似乎无法让它出现。请帮忙...
我的 xsl 包括以下内容。
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml">
<xsl:output method="xml" encoding="utf-8" doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" indent="yes"/>
我的 C# 代码如下所示:
try
{
XPathDocument myXPathDoc = new XPathDocument(myPath);
XslTransform myXslTrans = new XslTransform();
myXslTrans.Load(ConfigurationManager.AppSettings["XsltFilePath"] == null ?
"MyTransform.xsl" :
ConfigurationManager.AppSettings["XsltFilePath"]);
String htmlFile = Path.Combine(myFolder, myName, "index.html");
XmlTextWriter myWriter = new XmlTextWriter(htmlFile, null);
myXslTrans.Transform(myXPathDoc, null, myWriter);
myWriter.Close();
}
catch (Exception e)
{
System.Console.WriteLine(e.Message + "\n" + e.StackTrace);
}
任何想法我做错了什么?我正在使用 .NET 4.0。提前致谢。