Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/variables/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xslt XSL:将position()的结果赋给变量_Xslt_Variables_Position_Xquery - Fatal编程技术网

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>