XQuery is to XML what SQL is to database tables.
XQuery was designed to query XML data.
XQuery对于XML,就像SQL对于数据库表。
XQuery被设计用来查询XML数据。
W3C规范:http://www.w3schools.com/xquery/
http://www.w3schools.com/xquery/xquery_reference.asp
XQuery对XML的处理很直观,很强大,基于XPath表达式,被各种数据库支持。
而且XQuery与XPath关系紧密(相同的数据模型、相同的函数和操作)。
XQuery的历史与入门:http://www.ibm.com/developerworks/cn/xml/x-xquery.html
XQuery使用:http://www.xquery.com/tutorials/xquery_tutorial/
XQuery函数:http://www.xquery.com/tutorials/xquery-functions/
比较好的Xquery工具有XMLSpy。
XQuery示例:
支持的操作“:
Operator | Description | Example | Return value |
---|---|---|---|
| | Computes two node-sets | //book | //cd | Returns a node-set with all book and cd elements |
+ | Addition | 6 + 4 | 10 |
- | Subtraction | 6 - 4 | 2 |
* | Multiplication | 6 * 4 |
24 |
div | Division | 8 div 4 | 2 |
= | Equal | price=9.80 | true if price is 9.80 false if price is 9.90 |
!= | Not equal | price!=9.80 | true if price is 9.90 false if price is 9.80 |
< | Less than | price<9.80 | true if price is 9.00 false if price is 9.80 |
<= | Less than or equal to | price<=9.80 | true if price is 9.00 false if price is 9.90 |
> | Greater than | price>9.80 | true if price is 9.90 false if price is 9.80 |
>= | Greater than or equal to | price>=9.80 | true if price is 9.90 false if price is 9.70 |
or | or | price=9.80 or price=9.70 | true if price is 9.80 false if price is 9.50 |
and | and | price>9.00 and price<9.90 | true if price is 9.80 false if price is 8.50 |
mod | Modulus (division remainder) | 5 mod 2 | 1 |
XSD String
XSD Date
XSD Numeric
XSD Misc
Misc包括:boolean, base64Binary, hexBinary, float, double, anyURI, QName, and NOTATION.
XQJ(XQuery for Java API) 是在 Sun 的支持下作为 Java Community Process, JSR 225的一部分开发的。
直接使用XQuery操作xml,data direct xquery: http://www.stylusstudio.com/xquery/
XQJ入门:http://www.xquery.com/tutorials/xqj_tutorial/
java里使用XQuery:http://www.xquery.com/tutorials/xquery-java/
XQEngine:作者自己基于 Java 的开放源码查询引擎。现在有点落后了,因为至少目前作者放弃了跟踪规范的修改。
xmlbeans对xquery的支持:http://xmlbeans.apache.org/docs/2.0.0/guide/conSelectingXMLwithXQueryPathXPath.html
selectPath for XPath and execQuery for XQuery.
saxon对xquery的至支持:http://saxon.sourceforge.net/
queryExpression.run(dynamicQueryContext, result, props); //http://www.ibm.com/developerworks/cn/xml/x-xquerymashup/
其他:
c++的xquery支持 xqilla:http://xerces.apache.org/xerces-c/applications.html