Posted on 2008-05-29 14:49
G_G 閱讀(1181)
評論(1) 編輯 收藏 所屬分類:
xml Related
xml 數(shù)據(jù)庫使用,和XQuery使用.
環(huán)境:
??? 1.xml數(shù)據(jù)庫使用

(參考:eXist
Quick Start)
??? 2.xQuery
XQuery 首頁???
1.測試開始:
??? 進(jìn)入: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
>
|
使用數(shù)據(jù):
??? 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>
結(jié)果:
<minPrice><test>1</test>
<test>2</test>
<test>3</test>
<test>4</test>
<test>5</test>
</minPrice>