嗨,我是 xquery 和 xquery 中正则表达式的新手。我有一个 xml 标签,我想找到它的某个部分..即。somethingjpg 但不让它寻找.jpg。问题是 somethingjpg 并不总是在同一个空间中。
这是一个 xml 示例:
<book title="Harry Potter">
<description
xlink:type="simple"
xlink:href="http://book.com/2012/12/28/20121228-there_is_somethingjpg_123456789a1s23e4.jpg"
xlink:show="new">
As his fifth year at Hogwarts School of Witchcraft and
Wizardry approaches, 15-year-old Harry Potter is.......
</description>
</book>
或者 xlink:href 可以是这样的..
<book title="Harry Potter">
<description
xlink:type="simple"
xlink:href="http://book.com/2012/12/28/20121228-there_is_always_more_to_somethingelsejpg_123456789a1s23e4.jpg"
xlink:show="new">
As his fifth year at Hogwarts School of Witchcraft and
Wizardry approaches, 15-year-old Harry Potter is.......
</description>
</book>
我想要实现的(如果可能的话)是一段 xquery 代码,它将查找 somethingjpg 或 somethingelsejpg。然后修复somethingjpg 或somethingelsejpg 只说一些东西或其他东西,再次将链接全部连接在一起,并在eXist-db中的旧链接上替换新链接
代码明智我有..
let $a := collection('/db/articles/')//book
for $b in $a//@xlink:href[contains(.,'jpg_')]
let $c := tokenize(replace($b, 'Some sort of redex I can't figure out', '$1;$2;$3'), ';')
let $d := $c[2]
let $e := replace(substring-before($d, 'jpg_'). '_')
let $f := concat ($c[1]. $e, $c[3])
return update replace $b with $f
我就是想不通剩下的……救命!!