如何在Saxon中向XPath添加字符串函数?
我想创建一个函数,它可以在字符串中找到一个单词,比如如何在Saxon中向XPath添加字符串函数?,xpath,saxon,Xpath,Saxon,我想创建一个函数,它可以在字符串中找到一个单词,比如 word(@class, 'items') 等于 fn:matches(@class, "(^|\s)items(\s|$)") 有多种方法可以做到这一点,但最简单的解决方案是使用XQuery,它允许您在语言中定义函数: declare function local:word($a as xs:string, $b as xs:string) as xs:boolean { matches($a, concat("(^|\s)", $
word(@class, 'items')
等于
fn:matches(@class, "(^|\s)items(\s|$)")
有多种方法可以做到这一点,但最简单的解决方案是使用XQuery,它允许您在语言中定义函数:
declare function local:word($a as xs:string, $b as xs:string) as xs:boolean {
matches($a, concat("(^|\s)", $b, "(\s|$)"))
};
这里是我对XSLT2.0的发现