xslt - XSLT:检查字符串 A 是否包含标记化字符串 B 的任何元素
问题描述
我有一个分隔字符串source
,我想知道它是否有任何标记化的子字符串target
(也可以被标记化)。XSLT 函数过滤器是否提供此结果?
<xsl:variable name="source">2.0;2.1;2.2;2.3</xsl:variable>
<xsl:variable name="target">2.2;3.0</xsl:variable>
<xsl:variable name="source_tokenized">
<xsl:value-of select="tokenize($source,';')"/>
</xsl:variable>
<xsl:value-of select="filter($source_tokenized ,contains($target,.))"/>
在此示例中,2.2
包含在 中2.2;3.0
,因此在这种情况下,源的标记之一确实包含在目标中。
当我收到一条消息时,我的语法不正确
static error near {...versions ,contains($target,...} in expression in xsl:value-of/@select on line 368 column 83 of stylesheet.xsl:
XPST0017: Cannot find a 2-argument function named
Q{http://www.w3.org/2005/xpath-functions}filter(). Higher-order functions are not
available in this Configuration
Errors were reported during stylesheet compilation
- 是
filter
这个工作的功能吗?如果是这样,我该如何使用它? - 如果没有,有什么更好的方法?(需要一般建议,而不是实际代码。)
解决方案
我想知道它的任何标记化子字符串是否在目标中
这个表达式:
tokenize($target, ';') = tokenize($source, ';')
如果true()
其中至少有一个令牌$target
等于$source
. 否则它将返回false()
。
推荐阅读
- r - 如何在 Sparklyr 中正确使用特征转换函数
- r - 如果满足条件,则通过从另一个 DF 中提取数据来将数据附加到当前 DF
- laravel - laravel:图像文件,取消链接(public_path())不起作用并显示权限被拒绝
- javascript - 如何实现 Tableau 可信身份验证?
- dronekit-python - 如何隐藏 DroneKit-Python API 消息
- c# - TextBox为空时如何禁用按钮?
- javascript - Chrome 扩展程序:在时间到来之前触发警报
- python - 一个 dask 工作线程在线程调度程序中使用多少个线程?
- redux - Redux - 将状态传递给其他组件
- chart.js - 雷达图 - 在 chart.js 中显示顶点附近的值