XQuery与XQJ的介绍与使用

来源:互联网 发布:淘宝书店赚钱吗 编辑:程序博客网 时间:2024/06/04 04:19

1.XQuery

XQuery

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示例:

  • Extract information to use in a Web Service
  • Generate summary reports
  • Transform XML data to XHTML
  • Search Web documents for relevant information

支持的操作“:

OperatorDescriptionExampleReturn value|Computes two node-sets//book | //cdReturns a node-set with all book and cd elements+Addition6 + 410-Subtraction6 - 42*Multiplication

6 * 4

24divDivision8 div 42=Equalprice=9.80true if price is 9.80
false if price is 9.90!=Not equalprice!=9.80true if price is 9.90
false if price is 9.80<Less thanprice<9.80true if price is 9.00
false if price is 9.80<=Less than or equal toprice<=9.80true if price is 9.00
false if price is 9.90>Greater thanprice>9.80true if price is 9.90
false if price is 9.80>=Greater than or equal toprice>=9.80true if price is 9.90
false if price is 9.70ororprice=9.80 or price=9.70true if price is 9.80
false if price is 9.50andandprice>9.00 and price<9.90true if price is 9.80
false if price is 8.50modModulus (division remainder)5 mod 21支持的函数:

  • Accessor
  • Error and Trace
  • Numeric
  • String
  • AnyURI
  • Boolean
  • Duration/Date/Time
  • QName
  • Node
  • Sequence
  • Context
支持的数据类型(源于XSD 1.0):

XSD String

XSD Date

XSD Numeric

XSD Misc

Misc包括:boolean, base64Binary, hexBinary, float, double, anyURI, QName, and NOTATION.

2.XQJ

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


原创粉丝点击