|
>Home>Products>DataDirect XQuery>FAQ
Print
What is DataDirect XQuery? The DataDirect XQuery FAQ
What is DataDirect XQuery? DataDirect XQuery is the first embeddable component for XQuery that implements the XQuery API for Java (XQJ).
It supports all major relational databases on any Java platform. DataDirect XQuery allows you to query XML, relational databases,
or a combination of the two, integrating the results for XML-based data exchange, XML-driven Web sites, and other applications
that require or leverage the power of XML.
DataDirect XQuery is designed for software developers and independent software vendors (ISVs) who need to manage heterogeneous data sources in XML applications.
This page provides answers to some of the most frequently asked questions about DataDirect XQuery and XQuery-related technologies. If you prefer, you can
view a PDF document of DataDirect XQuery FAQs.
And if you have a question that isn't answered here, drop us a line and we'll get you an answer.
What language can I use to query XML?
You can use XQuery, an XML query language, to query XML data sources. In addition, you can use XQuery to query any type
of data that can be virtually represented as XML.
What is XQuery?
XQuery is a query language that was designed as a native XML query language. Because most types of data can be represented as XML,
XQuery can also be used to query other types of data. For example, XQuery can be used to query relational data using an XML view of a
relational database. This is important because many Internet applications need to integrate information from multiple sources,
including data found in web messages, relational data, and various XML sources. XQuery was specifically designed for this kind of data integration.
For example, suppose your company is a financial institution that needs to produce reports of stock holdings for each client.
A client requests a report with a Simple Object Access Protocol (SOAP) message, which is represented in XML. In most businesses,
the stock holdings data is stored in multiple relational databases, such as Oracle, Microsoft SQL Server, or DB2. XQuery can query
both the SOAP message and the relational databases, creating a report in XML.
XQuery is based on the structure of XML and leverages that structure to make it possible to perform queries on any type of data
that can be represented as XML, including relational data. In addition, XQuery API for Java (XQJ) lets your queries run in any environment
that supports the J2EE platform.
What is the current status of XQuery?
XQuery is currently under development at the W3C, which is a standards body for the World Wide Web.
The XQuery specification is currently a W3C Candidate Recommendation. The W3C maintains a home page for XQuery,
including pointers to the XQuery specifications, tutorials, and a variety of products, at http://http://www.w3.org/XML/Query.html.
What is XQJ?
The XQuery API for Java (XQJ) is designed to support the XQuery language, just like the JDBC API supports the SQL query language.
XQJ is based on the XQuery Data Model rather than the relational model. It allows a Java application to submit XQuery queries to data
sources and process the results.
The XQJ standard (JSR 225) is being developed under the Java Community Process.
Why do I need XQJ?
You need the XQuery API for Java (XQJ) to allow a Java application to submit XQuery queries to XML and relational data sources and process the results.
XQJ allows a Java program to configure connections, issue XQuery queries, and obtain results. XQJ is to XQuery what JDBC is to SQL.
The XQJ standard (JSR 225) is being developed under the Java Community Process.
Why would I use XQuery to query relational data?
Why would I use XQuery for XML reporting and Web publishing?
Many applications need to process relational data to create complex reports, and they need these reports in XML. In addition,
most commercial web pages use relational data, but it rarely looks like relational data when it is presented to the user.
These sites combine information from many sources, creating complex web pages that are user friendly. For relational data,
XQuery can be thought of as an XML-based report writing language. Similarly, SOAP messages are hierarchical XML, but the data
found in them frequently comes from relational databases, and XML is also used in many print-based database publishing applications.
Why would I use XQuery in a Java application?
The benefits of Java are well-known. It lets you write applications that work on any operating system, and the J2EE platform
provides robust support for XML, security, web services, and database connectivity. Embedding XQuery in Java applications can
significantly reduce the amount of Java code that is needed, because XQuery often is easier to use and more efficient than Java
for processing XML or querying relational data to create XML.
The XQuery for Java API (XQJ) is being developed to allow Java applications to use XQuery much like JDBC allows Java applications
to use SQL. Using DataDirect XQuery, a Java application that embeds or references an XQuery query can run on most operating systems,
can use data from most relational databases, and can access XML through the standard Java XML APIs (SAX and DOM, for example).
Why would I use XQuery for Web Services?
Web Services depend heavily on XML for both its definition language, Web Services Description Language (WSDL), and its messaging protocol,
Simple Object Access Protocol (SOAP). XQuery provides a language that can interact with XML data and other types of data as long as they can
be represented as XML. For example, XQuery can be used to access the content of messages or to construct new messages to be passed to a Web service.
In addition, you often need data to process Web Services results. XQuery can process SOAP messages and create the XML needed for result messages.
How can I query both XML sources and relational databases with a single query?
The best way to explain how a single XQuery query can query both XML and relational data sources is to show an example.
Suppose your company is a financial institution that needs to produce reports of stock holdings for each client. A client requests
a report with a Simple Object Access Protocol (SOAP) message, which is represented in XML. In most businesses, the stock holdings data
is stored in multiple relational databases, such as Oracle, Microsoft SQL Server, or DB2. XQuery can query both the SOAP message and
the relational databases, creating a report in XML. The XQuery query is processed using an XQuery implementation, such as DataDirect XQuery.
The following example joins an XML document (our SOAP message) named "request.xml" to two relational database tables named "holdings"
and "statistical". The request.xml XML document is joined to the "holdings" table by the userId attribute in the XML file and the userId
column of the "holdings" table. The two tables are joined by the ticker column of the "statistical" table and the stockticker column of the "holdings" table.
let $request := doc('request.xml')/request
for $user in $request/performance/UserId
return
<portfolio UserId="{$user}">
{$request }
{
for $st in collection('holdings')/holdings,
$stats in collection('statistical')/statistical
where $st/userid = $user
and $stats/ticker = $st/stockticker
return
<stock>
{ $stats/companyname }
{ $st/stockticker }
{ $st/shares }
{ $stats/annualrevenues }
</stock>
}
</portfolio>
Result
The result of this query is an element named portfolio. The first child of this element contains the original
request from request.xml. After that, the query provides the stock information for a given user, taken from two tables.
<portfolio UserId="Jonathan">
<request>
<performance>
<UserId>Jonathan</UserId>
<start>2003-01-01</start>
<end>2004-06-01</end>
</performance>
</request>
<stock>
<companyname>Amazon.com, Inc.</companyname>
<stockticker>AMZN</stockticker>
<shares>3000</shares>
<annualrevenues>7780</annualrevenues>
</stock>
<stock>
<companyname>eBay Inc.</companyname>
<stockticker>EBAY</stockticker>
<shares>4000</shares>
<annualrevenues>22600</annualrevenues>
</stock>
<stock>
<companyname>Int'l Business Machines C</companyname>
<stockticker>IBM</stockticker>
<shares>2500</shares>
<annualrevenues>128200</annualrevenues>
</stock>
<stock>
<companyname>Progress Software</companyname>
<stockticker>PRGS</stockticker>
<shares>23</shares>
<annualrevenues>493.4</annualrevenues>
</stock>
</portfolio>
What is DataDirect XQuery?
DataDirect XQuery™ is an implementation of XQuery that can query XML, relational data, SOAP messages, EDI, or a combination of data sources. It provides the fastest, most reliable and scalable XQuery support for all major relational databases and runs on any J2SE 1.4 or higher Java platform. DataDirect XQuery supports the XQuery API for Java (XQJ), and is easily embeddable into any Java program. It does not require any other product or application server, and has no server of its own. DataDirect XQuery is recommended for applications dealing with XML, relational, and legacy formats, including data integration, XML-based data exchange, web services, XML-driven web sites, and XML publishing.
DataDirect XQuery provides a streaming XML adaptor to drastically reduce the amount of memory needed when processing large XML documents. Performance enhancements and configurable scalability options provide optimal query performance in any environment.
The following architectural diagram shows the components of DataDirect XQuery and the flow involved in accessing XML, relational data, and other non-XML sources.

What benefits does DataDirect XQuery provide over other XQuery products?
DataDirect XQuery is ideal for any company that needs to access and integrate data stored in XML and relational sources.
Unlike other XQuery products, DataDirect XQuery provides the following benefits:
- DataDirect XQuery is database and platform independent.
- DataDirect XQuery provides good performance when querying relational databases because it allows the XQuery query to be executed
as efficiently as possible (decomposing the query into SQL statements) and moving out of the database just the minimum amount of data.
Other XQuery products return large chunks of data and then perform additional steps to retrieve the required data, which slows processing.
- DataDirect XQuery supports XML streaming to drastically reduce the amount of memory required when processing large XML documents.
Other XQuery products do not support XML streaming.
- DataDirect XQuery does not require its own server infrastructure, which makes it easy to embed into other commercial applications.
Why can't I just use a free XQuery implementation, such as Saxon, instead of DataDirect XQuery?
If you want to query and integrate both XML and relational data, DataDirect XQuery provides substantial benefits in performance over a free
implementation such as Saxon:
- DataDirect XQuery provides support for all major databases on any platform. In contrast, Saxon only has minimal support for data stored in relational databases.
- DataDirect XQuery provides good performance when querying relational databases because it allows the query to be executed as efficiently as possible
(decomposing the query into SQL statements) and moving out of the database just the minimum amount of data. Other XQuery products return large chunks
of data and then perform additional steps to retrieve the required data, which slows processing.
- DataDirect XQuery supports XML streaming to drastically reduce the amount of memory required when processing large XML documents.
Saxon and many other XQuery products do not support XML streaming.
- DataDirect Technologies provides comprehensive, award-winning technical support. Technical support is not usually available with free implementations.
How is DataDirect XQuery different from the XQuery implementations planned by the big database vendors?
Microsoft and Oracle support XQuery in their products. Unlike the XQuery implementations from database vendors, DataDirect XQuery is database
and platform independent. Using DataDirect XQuery, you can write applications that work for all major databases as well as XML data sources.
Can I embed DataDirect XQuery into a commercial application?
Yes. DataDirect XQuery does not require its own server infrastructure, which makes it easy to embed into other commercial applications.
Which platforms does DataDirect XQuery run on?
DataDirect XQuery is implemented in Java and runs on any J2SE 1.4 or higher Java platform.
Which relational databases does DataDirect XQuery support?
DataDirect XQuery supports the following databases:
- DB2 V9.1 for Linux, UNIX, and Windows 3.1
- DB2 V9.1 for z/OS 3.1
- DB2 UDB v8.x for Linux, UNIX, and Windows 3.1
- DB2 UDB v8.1 for z/OS 3.1
- DB2 UDB V5R2, V5R3, V5R4 for iSeries
- Informix Dynamic Server 9.4, 10, 11
- MS SQL Server 2005 3.1
- MS SQL Server 2000 3.1
- MS SQL Server 2000 Desktop Engine (MSDE 2000) 3.1
- MS SQL Server 2000 Enterprise Edition (64-bit)
- MySQL Enterprise 5.0.x
- Oracle 11g 3.1
- Oracle 10g R1, R2 (10.1, 10.2) 3.1
- Oracle 9i R1, R2 (9.0.1, 9.2)
- PostgresSQL 8.1, 8.2 (Requires the PostgreSQL JDBC driver.)
- Sybase Adaptive Server Enterprise 12.5.1, 12.5.2, 12.5.3, 12.5.4, 15.0
What types of XML does DataDirect XQuery support access to?
DataDirect XQuery can access XML data sources that have the following physical formats:
Which version of the XQuery specification does DataDirect XQuery support?
DataDirect XQuery supports the W3C XQuery Recommendation of January, 2007.
Can I use DataDirect XQuery to update data?
Yes. DataDirect XQuery supports updates to relational database tables from inside an XQuery by providing three built-in functions. These functions are: ddtek:sql-insert, ddtek:sql-update, ddtek:sql-delete.
How easy is DataDirect XQuery to configure?
Configuring DataDirect XQuery for your environment is straightforward. Once installed, you configure a source configuration file to specify the
connection information for XML and relational data sources that are used by XQuery queries. To make this configuration easy, DataDirect XQuery ships
with an example source configuration file for each database that the product supports, so you can start with one of these example files and modify the values as needed.
How do I develop a Java application that executes an XQuery using DataDirect XQuery?
Java applications use the XQuery for Java API (XQJ) to execute XQuery, which is analogous to using the JDBC API to execute SQL
statements. The following sample Java code illustrates the basic steps that an application would perform to execute an XQuery expression using
DataDirect XQuery.
...
// import the XQJ classes
import com.ddtek.xquery.*;
import com.ddtek.xquery.xqj.mediator.DDXQDataSource;
// establish a connection to a data source
DDXQDataSource ds = new DDXQDataSource();
ds.setJdbcUrl("jdbc:xquery:sqlserver://server1:1433;
databaseName=stocks");
XQConnection conn = ds.getConnection("myuserid", "mypswd");
// create an expression object that is used to execute a query
XQExpression expr = conn.createExpression();
// the query
String es = "for $h in collection('holdings')/holdings " +
"where $h/stockticker='AMZN' " +
"return $h";
// execute the query
XQResultSequence result = expr.executeQuery(es);
System.out.println(result.getSequenceAsString());
// free all resources
result.close();
expr.close();
conn.close();
Additional XQJ examples covering different scenarios are shipped with DataDirect XQuery.
Where can I learn more about XQuery and XQJ?
Where can I learn more about DataDirect XQuery?
Information about DataDirect XQuery can be found at http://www.datadirect.com/products/xquery/index.ssp.
|
Stay Informed!
XQuery is one of the hottest XML technologies being developed today. Stay informed with vital news about
standards, tools, and trends by signing up for the DataDirect XQuery newsletter.
Try DataDirect XQuery Free!
Put the power, scalability, and performance of DataDirect XQuery to work for you today! Our free trial
lets you see for yourself how easy it is to build data integration applications that access relational, EDI, and other file formats as XML!
Download DataDirect XQuery today!
Query Relational Data with DataDirect XQuery
Back to School with DataDirect XQuery
Getting your mind around the possibilities of a data integration technology as promising as XQuery can be difficult, but our
XML developers Webinars will help you understand the
power and versatility of XQuery, and our favorite XQuery processor, DataDirect XQuery.
From information about how to leverage relational data to
real-world use cases, our Webinars will help you see why
DataDirect XQuery is the best choice for today's tough data integration and aggregation challenges.
Are You Ready for the XQuery Revolution?
Free XQuery Development Resources
DataDirect XQuery Features
Use DataDirect XQuery to Mine Relational Data!
This informative XQuery webinar shows you how scalable, flexible,
and reliable DataDirect XQuery is for building XML applications that access data from relational databases, XML, Web services and legacy formats; and how it uses
document projection and data streaming technologies to efficiently query large (Gigabytes) XML documents.
Check our XQuery Webinars page for more information on this and other Webinar topics.
DataDirect XQuery Data Integration Solutions
DataDirect XQuery for XML Publishing and More!
In this informative XQuery webinar, it's discussed how XQuery and the XQuery API for Java (XQJ) can be used in Java applications for XML report writing, XML publishing,
Web publishing, Web services, and XML data services.
Check our XQuery Webinars page for more information on this and other XQuery webinar
topics.
|