XPath name()函数是否是当前元素?

问题描述 投票:1回答:2

给出此XML

<some>
    <where>
        <in>
            <hell></hell>
        </in>
    </where>
</some>

和此XSLT

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
  <xsl:output method="text" />

  <xsl:template match="in">
    this is a <xsl:value-of select="name()"/>
    this is a <xsl:value-of select="ancestor::where/name()"/>
  </xsl:template>
</xsl:stylesheet>

第一个value-of返回“ in”;第二个是语法错误。我本来希望看到"where",但是在这里我无法开始理解语法。

xml xslt xpath syntax
2个回答
1
投票

您似乎在使用XSLT 1处理器和XPath 1,在XPath中您不能在最后一步调用函数,该功能仅在XPath 2中引入。


0
投票

如Martin Honnen所提到的,[XPath 2.0必须在XPath表达式的最后一步中使用函数。

© www.soinside.com 2019 - 2024. All rights reserved.