Xslt XSL:将position()的结果赋给变量
我试图分配一个元素的位置,如下所示:Xslt XSL:将position()的结果赋给变量,xslt,variables,position,xquery,Xslt,Variables,Position,Xquery,我试图分配一个元素的位置,如下所示: <xsl:variable name="offset" select="ancestor::myparent/position() * 8"/> 有办法做到这一点吗?position()仅在引用特定上下文时可用 处理myparent元素时,应设置变量 <xsl:template match="myparent"> <xsl:variable name="offset" select="position() * 8"/>
<xsl:variable name="offset" select="ancestor::myparent/position() * 8"/>
有办法做到这一点吗?position()仅在引用特定上下文时可用
处理myparent
元素时,应设置变量
<xsl:template match="myparent">
<xsl:variable name="offset" select="position() * 8"/>
<xsl:apply-templates>
<xsl:with-param name="offset" select="$offset"/>
</xsl:apply-templates>
</xsl:template>
类似上面的东西。确保向需要偏移量的模板添加参数
<xsl:template match="myparent">
<xsl:variable name="offset" select="position() * 8"/>
<xsl:apply-templates>
<xsl:with-param name="offset" select="$offset"/>
</xsl:apply-templates>
</xsl:template>