嗨,我是一個新手到xquery和在xquery中使用reguler表達式。我有一個xml標籤,我想找到它的某個位。也就是說。 somethingjpg但沒有找到.jpg。問題是,somethingjpg並不總是在同一個空間..xquery的正則表達式...有沒有更簡單的方法
下面是一個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只是說些什麼或somethingelse,CONCAT鏈接所有再度合作並替換的存在,但分貝
代碼明智的我在舊鏈接新鏈接..
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
我無法弄清其餘的......幫助!
如果您提供了一個希望輸出以清除問題的例子,也許有人甚至會提供解決方案。 –