2008年9月25日星期四

xquery 简单使用

一、测试执行 xquery 的方法:

1. 用工具
比如 stylus studio (www.stylusstudio.com)

2. 利用 Saxon
命令行如下: java -cp saxon8.jar net.sf.saxon.Query test.xml
其中 test.xml 的内容可以如下:

doc('http://www.stylusstudio.com/examples/videos.xml')

//actors/actor[@id="00000030"]

二、xquery 的 FLWOR(pronounced flower) 表达式 for/let/where/order by/return

比如:
let $doc := doc('http://www.stylusstudio.com/examples/videos.xml')
for $v in $doc//video,$a in $doc//actors/actor
where ends-with($a, 'Lisa') and $v/actorRef = $a/@id
return $v/title

没有评论: