我现在知道了。我有一个必须使用 xslt 工作表转换的 XML 文档。我的代码如下:
Dim xStream As New IO.MemoryStream
' Create the XslCompiledTransform and load the stylesheet.
Dim xslt As New XslCompiledTransform()
xslt.Load(strLKxsl)
' Create the XslCompiledTransform and load the stylesheet.
Dim xslt As New XslCompiledTransform()
xslt.Load(strXSLfolder & "xslt_lookup.xslt")
' Create the XsltArgumentList.
Dim xslArg As New XsltArgumentList()
Using w As XmlWriter = XmlWriter.Create(xStream)
' Transform the file.
xslt.Transform(xmldLookup, Nothing, w)
End Using
我在 xslt.Transform(xmldLookup, Nothing, w) 行收到以下错误:
处于 EndRootElement 状态的令牌 StartElement 将导致无效的 XML 文档。如果要编写 XML 片段,请确保将 ConformanceLevel 设置设置为 ConformanceLevel.Fragment 或 ConformanceLevel.Auto。
这是 XML 文件的内容:
<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="includes/xslt_lookup.xslt"?>
<lookup xmlns="logis-online:lk"
title="<Document Title>"
nexturl="<URL>">
<search visible="false">
<field id="SUPPLIER_NO" hidden="true" size="10"
value="<Value>" />
<field id="WEB_STORE_NO" hidden="true" size="10"
value="<Value>" />
<field id="REST" hidden="true" size="40" value="" />
<field id="LOOKUP_ACTION" hidden="true" size="1" value="<Value>" />
<field id="WEB_ACTION" hidden="true" size="2" value="<Value>" />
</search>
<results>
<header>
<section>
<item id="SUPPLIER_NO" title="Supplier No" value="<Value>"
HelpID="10" />
<item id="SUPPLIER_NAME_SHORT" title="Supplier Name"
value="<Value>" HelpID="10" />
<item id="LIABLE_STORE_NO" title="Liable Store No"
value="<Value>" HelpID="98" />
</section>
</header>
<list target="<lookup aspx page>" />
</results>
</lookup>