Xml XPath文本(或属性)等于值的位置
XML:Xml XPath文本(或属性)等于值的位置,xml,xslt,xpath,position,Xml,Xslt,Xpath,Position,XML: href 其他 A. B XSLT:(我确保我在下面模板的第[@type='data']/行) 如何获取text()等于href的列位置?如果更简单,我可以为值为'href'的列指定一个属性。示例:href 编辑: 我尝试了以下方法,但没有成功 XSLT: 简单的答案是testt是一个变量,因此需要使用$前缀来引用它 <xsl:template match="column" mode="panelTabsBody"> <xsl:variable name=
href
其他
A.
B
XSLT:(我确保我在下面模板的第[@type='data']/行)
如何获取text()等于href的列位置?如果更简单,我可以为值为'href'的列指定一个属性。示例:href
编辑:我尝试了以下方法,但没有成功
XSLT:
简单的答案是testt
是一个变量,因此需要使用$
前缀来引用它
<xsl:template match="column" mode="panelTabsBody">
<xsl:variable name="testt" select="count(../../row[@type='header']/column[text()='href']/preceding-sibling::column) + 1" />
<td>
<a>
<xsl:attribute name="href">
<xsl:value-of select="../../row[@type='header']/column[position() = testt]" />
</xsl:attribute>
</a>
</td>
</xsl:template>
当然,这是为“header”行选择列,您已经知道该行包含“href”。也许你只需要这样做
<xsl:value-of select="../../row[@type='header']/column[position() = $testt]" />
<xsl:template match="column" mode="panelTabsBody">
<xsl:variable name="testt" select="count(../../row[@type='header']/column[text()='href']/preceding-sibling::column) + 1" />
<td>
<a>
<xsl:attribute name="href">
<xsl:value-of select="../../row[@type='header']/column[position() = testt]" />
</xsl:attribute>
</a>
</td>
</xsl:template>
<xsl:value-of select="../../row[@type='header']/column[position() = $testt]" />
<xsl:value-of select="../column[position() = $testt]" />