在 XSLT 中使用动态 xpath [英] Using dynamic xpath in XSLT

查看:28
本文介绍了在 XSLT 中使用动态 xpath的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 XSLT 中使用变量 xpathvar,其值将在调用 XSLT 时提供.我怎样才能做到这一点?我的 XSLT 文件看起来像 -

I am using a variable say xpathvar in the XSLT whose value will be supplied at the time of call to XSLT. How can i achieve this? My XSLT file looks like -

<xsl:param name="xpathvar"/>
<xsl:param name="keyxpath"/>
 <xsl:template match="/">
  <listofResults>
    <xsl:for-each select="$xpathvar">
    <keyvalues><xsl:value-of select="xalan:evaluate(substring-before($keyxpath,'||'))"/></keyvalues>
    <keyvalues><xsl:value-of select="xalan:evaluate(substring-after($keyxpath,'||'))"/></keyvalues>
    </xsl:for-each>
  </listofResults>
 </xsl:template>
</xsl:stylesheet>

如果我在 for-each 中提到变量,它会抛出错误.请指导我如何实现这一目标.

If I mention the variable in the for-each, it throws error. Please guide how can I achieve this.

谢谢!

推荐答案

根据 全局 xsl:param 包含 xpath 表达式字符串 它不能完全使用普通的旧 XSLT 来完成,您需要使用 evaluate 扩展名,请参阅:Xalan 求值表达式

According to Global xsl:param containing xpath expression string it can't be done purely with plain old XSLT, you need to use the evaluate extension see: Xalan evaluate expression

这篇关于在 XSLT 中使用动态 xpath的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆