给定此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"
,但是我无法在这里开始理解语法。
最佳答案
您似乎在使用XSLT 1处理器和XPath 1,但在XPath中您不能在最后一步调用函数,该功能仅在XPath 2中引入。
规范是在线的,因此如果您想了解有关XPath 1(XSLT 1中使用的表达语言)的规则的更多信息,请查阅https://www.w3.org/TR/xpath-10/。
关于xml - XPath name()函数是否用于当前元素?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59376221/