C# ';版本';不能是';转型';要素
我正在使用XslCompiledTransform.Load,每次收到错误消息时:C# ';版本';不能是';转型';要素,c#,xslt,xslcompiledtransform,C#,Xslt,Xslcompiledtransform,我正在使用XslCompiledTransform.Load,每次收到错误消息时: 'version' cannot be a child of the 'Transformation' element 这是样式表: <Transformation><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsof
'version' cannot be a child of the 'Transformation' element
这是样式表:
<Transformation><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:user="urn:my-scripts"
xmlns:exsl="http://exslt.org/common" extension-element-prefixes="exsl"><xsl:output
method="xml" /><xsl:template match="node() | @*"><xsl:copy><xsl:apply-templates
select="@* | node()" /></xsl:copy></xsl:template><xsl:template match="testlist"><xsl:copy>
<xsl:apply-templates select="test"><xsl:sort select="requestor/code" /></xsl:apply-
templates></xsl:copy></xsl:template></xsl:stylesheet></Transformation>
如果删除该版本,则会出现错误:缺少必需属性“version”
我是否因为使用标记“Transformation”中的样式表而出现错误?您的问题的答案是“是”。确实会出现错误,因为在
转换
元素中只有xsl:stylesheet
元素
<Transformation>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
xmlns:user="urn:my-scripts"
xmlns:exsl="http://exslt.org/common"
extension-element-prefixes="exsl">
<xsl:output method="xml"/>
<xsl:template match="/">
<Transformation>
<xsl:apply-templates select="@* | node()"/>
</Transformation>
</xsl:template>
<xsl:template match="node() | @*">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="testlist">
<xsl:copy>
<xsl:apply-templates select="test">
<xsl:sort select="requestor/code"/>
</xsl:apply-templates>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>