Xml XSLT1中XPATH表达式中的变量
我以前为此使用XSLT2.0,但出于某些原因,我决定使其与XSLT1.0兼容,并且根据我所读/发现的,变量在XSLT1.0的XPATH表达式中不起作用 这是我在XSLT 2.0中使用的原始XSL:Xml XSLT1中XPATH表达式中的变量,xml,xslt,xpath,Xml,Xslt,Xpath,我以前为此使用XSLT2.0,但出于某些原因,我决定使其与XSLT1.0兼容,并且根据我所读/发现的,变量在XSLT1.0的XPATH表达式中不起作用 这是我在XSLT 2.0中使用的原始XSL: <xsl:template match="footnote_ref"> <xsl:variable as="xs:integer" name="ref" select="."/> <xsl:variable name="fid" select="generate-
<xsl:template match="footnote_ref">
<xsl:variable as="xs:integer" name="ref" select="."/>
<xsl:variable name="fid" select="generate-id(../following-sibling::footnote_list[1]/footnote[$ref])"/>
<sup><a href="#{$fid}">
<xsl:value-of select="."/>
</a></sup>
</xsl:template>
如果我理解正确,这应该计算为生成id(../following sibling::footnote_list[1]/footnote[$ref])
,但替换为$ref
。在中,他们显示使用变量很好,但这仍然不起作用,行为就像没有dyn:evaluate
,完全忽略变量一样
我是否做错了什么或误解了dyn:evaluate
?如果重要的话,我将通过lxml(Python)使用libxslt
在XSLT1.0中,这是行不通的,它似乎忽略了[$ref]
部分,而不管怎样,只链接到第一个脚注
XSLT1.0不支持xsl:variable
上的as
属性。因此,在以下方面:
<xsl:template match="footnote_ref">
<xsl:variable name="ref" select="."/>
<xsl:variable name="fid" select="generate-id(../following-sibling::footnote_list[1]/footnote[$ref])"/>
<sup><a href="#{$fid}">
<xsl:value-of select="."/>
</a></sup>
</xsl:template>
然后,$ref
是一个数字,谓词将执行您需要的基于position()
的测试,您应该得到正确的脚注
在XSLT1.0中,这是行不通的,它似乎忽略了[$ref]
部分,而不管怎样,只链接到第一个脚注
XSLT1.0不支持xsl:variable
上的as
属性。因此,在以下方面:
<xsl:template match="footnote_ref">
<xsl:variable name="ref" select="."/>
<xsl:variable name="fid" select="generate-id(../following-sibling::footnote_list[1]/footnote[$ref])"/>
<sup><a href="#{$fid}">
<xsl:value-of select="."/>
</a></sup>
</xsl:template>
然后,$ref
是一个数字,谓词将执行您需要的基于position()
的测试,您应该得到正确的脚注
<xsl:variable name="ref" select="number(.)"/>