| FazBrowse Wikipedia Viewer | Main Page | | |
| Viewing: https://en.wikipedia.org/wiki/XQuery_API_for_Java |
| Contents |
|---|
| Examples |
| Basic example |
| Default data type mapping |
| Known implementations |
| Native XML databases |
| Relational databases |
| Non-database implementations |
| License |
| References |
| XQJ | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Developer | Java Community Process | |||||||||||||||||||||
element(), xs:integer or ContentHandler, StAX InputStream classes.
ExampleseditBasic exampleeditThe following example illustrates creating a connection to an XML Database, submitting an XQuery expression, then processing the results in Java. Once all of the results have been processed, the connection is closed to free up all resources associated with it. XQExpressionexpr=conn.createExpression();
// The XQuery expression to be executed
Stringes="declare variable $x as xs:integer external;"+
" for $n in fn:collection('catalog')//item"+
" where $n/price <= $x"+
" return fn:data($n/name)";
// Bind a value (21) to an external variable with the QName x
expr.bindInt(newQName("x"),21,null);
// Execute the XQuery expression
XQResultSequenceresult=expr.executeQuery(es);
// Process the result (sequence) iteratively
while(result.next()){
// Process the result ...
}
Default data type mappingeditMapping between Java and XQuery data types is largely flexible, however the XQJ 1.0 specification does have default mapping rules mapping data types when they are not specified by the user. These mapping rules bear great similarities to the mapping rules found in JAXB. The following table illustrates the default mapping rules for when binding Java values to external variables in XQuery expressions.
Known implementationseditNative XML databaseseditThe following is a list of Native XML Databases which are known to have XQuery API for Java implementations. Relational databaseseditDataDirect provide XQJ adapters for relational databases, by translating XQuery code into SQL on the fly, then converting SQL result sets into a format suitable for XQJ to process further. The following is a couple of known implementations. Non-database implementationseditThe following is a list of non-database XQuery processors which provide an XQuery API for Java interface (typically allowing query against documents parsed from XML in filestore, and held in memory as DOM or similar trees).
LicenseeditThe specification is marked as "Copyright © 2003, 2006 - 2009 Oracle. All rights reserved." The specification contains two separate licenses: a "specification license" and a "reference implementation license". The specification license allows free copying of the specification provided that copyright notices are retained; it also grants a license to create and distribute an implementation of the specification provided that it fully implements the entire specification, that it does not modify or extend any interfaces, and that it passes the compatibility tests. This provision has caused some controversy. Firstly, it is not universally accepted that implementing a published specification is something that requires a license (that is, that copyright law would disallow this in the absence of a license). Secondly, the license does not meet the criteria to qualify as an open source license (see Open Source Definition), because of the ban on making extensions and modifications. This has led some open source enthusiasts to challenge whether XQJ implementations can ever be considered truly open source. The license for the reference implementation is a fairly conventional BSD-style open source license. ReferenceseditZorba 2.5 ships with a long awaited XQJ binding, 14 June 2012
| ||||||||||||||||||||||