Posted on 2008-05-29 14:49
G_G 阅读(1172)
评论(1) 编辑 收藏 所属分类:
xml Related
xml 数据库使用,和XQuery使用.
环境:
1.xml数据库使用
(参考:eXist
Quick Start)
2.xQuery
XQuery 首页 1.测试开始:
进入:eXist-> http://demo.exist-db.org/xmldb/db/
for $x in doc("/examples2.xml")/exist:result/country
return if ($x/population_growth<-1)
then <child>{data($x/name)}</child>
else <adult>{data($x/name)}</adult> |
|
---|
parent collection: /db |
- <child
>
Bosnia and Herzegovina
</
child
>
|
- <adult
>
Czech Republic
</
adult
>
|
- <child
>
Estonia
</
child
>
|
- <child
>
Faroe Islands
</
child
>
|
- <adult
>
Hungary
</
adult
>
|
- <adult
>
Ireland
</
adult
>
|
- <child
>
Latvia
</
child
>
|
- <adult
>
Lithuania
</
adult
>
|
- <child
>
Romania
</
child
>
|
- <adult
>
Russia
</
adult
>
|
使用数据:
http://demo.exist-db.org/xmldb/db/examples2.xml
2:自定义方法:
使用:http://demo.exist-db.org/sandbox/sandbox.xql
declare function local:minPrice(){
for $x in (1 to 5)
return <test>{$x}</test>
};
<minPrice>{local:minPrice()}</minPrice>
结果:
<minPrice><test>1</test>
<test>2</test>
<test>3</test>
<test>4</test>
<test>5</test>
</minPrice>