1. XQuery
XQuery is to XML what SQL is to database tables.
XQuery was designed to query XML data.
XQuery for XML, just like SQL for database tables.
XQuery is designed to query XML data.
W3C specification: http://www.w3schools.com/xquery/
Http://www.w3schools.com/xquery/xquery_reference.asp
XQuery is intuitive and powerful in XML processing. It is supported by various databases based on XPath expressions.
In addition, XQuery is closely related to XPath (the same data model, the same functions and operations ).
Introduction to XQuery: http://www.ibm.com/developerworks/cn/xml/x-xquery.html
XQuery usage: http://www.xquery.com/tutorials/xquery_tutorial/
XQuery: http://www.xquery.com/tutorials/xquery-functions/
Better XQuery tools include xmlspy.
XQuery example:
- Extract information to use in a Web Service
- Generate summary reports
- Transform XML data to XHTML
- Search Web documents for relevant information
Supported operations:
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 |
Price <1, 9.80 |
True if price is 9.00 False if price is 9.80 |
<= |
Less than or equal |
Price <= 9.80 |
True if price is 9.00 False if price is 9.90 |
> |
Greater |
Price> 9.80 |
True if price is 9.90 False if price is 9.80 |
> = |
Greater than or equal |
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 |
Supported functions:
- Accessor
- Error and trace
- Numeric
- String
- Anyuri
- Boolean
- Duration/date/time
- QNAME
Supported data types (derived from XSD 1.0 ):
XSD string
XSD date
XSD numeric
XSD Misc
Misc includes: Boolean, base64binary, hexbinary, float, double, anyuri, QNAME, and notation.
2. xqj
Xqj (XQuery for Java API) is developed as part of Java Community process and JSR 225 with the support of sun.
Using XQuery directly to operate XML, data direct XQuery: http://www.stylusstudio.com/xquery/
Xqj entry: http://www.xquery.com/tutorials/xqj_tutorial/
Using XQuery in Java: http://www.xquery.com/tutorials/xquery-java/
Xqengine: the open source code Query Engine Based on Java. This is a bit backward, because at least the author has abandoned the revision of the tracking specification.
XmlbeansSupport of XQuery: http://xmlbeans.apache.org/docs/2.0.0/guide/conSelectingXMLwithXQueryPathXPath.html
Selectpath for xpath and execquery for XQuery.
SaxonSupport for XQuery: http://saxon.sourceforge.net/
queryExpression.run(dynamicQueryContext, result, props); //http://www.ibm.com/developerworks/cn/xml/x-xquerymashup/
Others:
C ++ XQuery supports xqilla: http://xerces.apache.org/xerces-c/applications.html