【发布时间】:2014-06-26 09:32:25
【问题描述】:
我正在尝试将 xml 路径作为字符串传递给模板。
<xsl:call-template name="checkPath">
<xsl:with-param name="path" select="'parent/child1'" />
</xsl:call-template>
在模板中,我将一个子元素附加到传递的字符串中,以检查是否存在具有路径和给定名称的子元素。
<xsl:template name="checkPath">
<xsl:param name="path"/>
<xsl:variable name="childElement" select="child-name"/>
<xsl:if test="$path/child2[name=$childElement]">
//Do some processing.
</xsl:if>
</xsl:template>
上面的 XSL 给了我以下错误。
Invalid conversion from 'java.lang.String' to 'node-set'.
我正在尝试解析以下 XML。
<parent>
<child1>
<child2>
<name>name1</name>
</child2>
</child1>
</parent>
.....
<child-name>name1</child-name>
【问题讨论】: