C# Xsl:Output元素和Xml:writer
我创建这个表单是为了用XSLT文件转换XML文件并创建一个文档文件。 通常,我使用Word打开XML文件,然后选择XSLT文件,然后使用样式创建文档文件 最后一页的代码是用C语言编写的,你能给我一些帮助在VisualBasic2008中进行翻译吗 将转换输出发送到XmlWriter对象时,XslTransform类忽略xsl:output设置。XslCompiledTransform类有一个OutputSettings属性,该属性返回一个XmlWriterSettings对象,该对象包含从样式表的xsl:output元素派生的输出信息。XmlWriterSettings对象用于创建具有可传递给Transform方法的正确设置的XmlWriter对象。以下C代码说明了此行为:C# Xsl:Output元素和Xml:writer,c#,visual-studio,xslt,visual-studio-2008,C#,Visual Studio,Xslt,Visual Studio 2008,我创建这个表单是为了用XSLT文件转换XML文件并创建一个文档文件。 通常,我使用Word打开XML文件,然后选择XSLT文件,然后使用样式创建文档文件 最后一页的代码是用C语言编写的,你能给我一些帮助在VisualBasic2008中进行翻译吗 将转换输出发送到XmlWriter对象时,XslTransform类忽略xsl:output设置。XslCompiledTransform类有一个OutputSettings属性,该属性返回一个XmlWriterSettings对象,该对象包含从样式表
// Create the XslTransform object and load the style sheet.
XslCompiledTransform xslt = new XslCompiledTransform();
xslt.Load(stylesheet);
// Load the file to transform.
XPathDocument doc = new XPathDocument(filename);
// Create the writer.
XmlWriter writer = XmlWriter.Create(Console.Out, xslt.OutputSettings);
// Transform the file and send the output to the console.
xslt.Transform(doc, writer);
writer.Close();
我用转换工具包翻译:
' Create the XslTransform object and load the style sheet.
Dim xslt As New XslCompiledTransform()
xslt.Load(stylesheet)
' Load the file to transform.
Dim doc As New XPathDocument(filename)
' Create the writer.
Dim writer As XmlWriter = XmlWriter.Create(Console.Out, xslt.OutputSettings)
' Transform the file and send the output to the console.
xslt.Transform(doc, writer)
writer.Close()
我根据自己的需要进行了修改:
注:
xml文件名=Fascicolo.xml
xslt filename=Stile.xslt
输出文件名=fascicolo.docx
感谢您在以下方面的特别合作:
' Create the XslTransform object and load the style sheet. File XSLT
Dim xslt As New XslCompiledTransform()
xslt.Load(Label4.Text)
' Load the file to transform. File XML
Dim doc As New Xml.XPath.XPathDocument(Label2.Text)
' Create the writer.
Dim writer As XmlWriter = XmlWriter.Create("Fascicolo.doc", xslt.OutputSettings)
' Transform the file and send the output to the console.
xslt.Transform(doc, writer)
writer.Close()
那跑得很好 这是一个可能的副本。我用工具翻译。很好,很好。Pero mi da un error mi aiuti?使用错误详细信息、堆栈跟踪、异常详细信息或其他信息编辑您的问题
' Create the XslTransform object and load the style sheet. File XSLT
Dim xslt As New XslCompiledTransform()
xslt.Load(Label4.Text)
' Load the file to transform. File XML
Dim doc As New Xml.XPath.XPathDocument(Label2.Text)
' Create the writer.
Dim writer As XmlWriter = XmlWriter.Create("Fascicolo.doc", xslt.OutputSettings)
' Transform the file and send the output to the console.
xslt.Transform(doc, writer)
writer.Close()