An XQJ Tutorial: Introduction to the XQuery API for Java

The XQuery API for Java (XQJ), currently in development under the Java Community Process as JSR 225, lets programmers use XQuery for XML processing and data integration applications, with full support for the Java Standard Edition (Java SE) and Java Enterprise Edition (Java EE) platforms. XQJ allows a Java program to connect to XML data sources, prepare and issue XQueries, and process the results as XML. This functionality is similar to that of JDBC, but the query language for XQJ is XQuery.

Starting with a simple XQuery/XQJ version of the familiar "Hello World!" application, this tutorial teaches you the basics of XQJ. Then, in easy-to-follow chapters, it covers XQJ's more advanced features, from serializing query results, to XML Pipelines, and more.

XQJ Tutorial Part I: An XQJ Introduction

Using an XQuery/XQJ version of the familiar "Hello World!" application, this chapter introduces you to some of the similarities between XQJ and JDBC like datasources and connections, as well as some of the concepts that make XQJ different, including data models, typing, and error handling.

Learn More

XQJ Tutorial Part II: Setting up an XQJ Session

An XQJ application always starts with accessing an XQDataSource object. The XQDataSource interface encapsulates all the parameters and settings needed to create a session with a specific implementation, and eventually execute XQuery expressions and process results. This chapter describes how to work with the XQDataSource interface in an XQJ application.

Learn More

XQJ Tutorial Part III: Querying Data from XML Files or Java XML APIs

In XQJ, XQExpression objects allow you to execute XQuery expressions. In this chapter of the XQJ Tutorial, you'll learn how to use XQExpression objects to query data, and how to use prepared queries to reduce expensive parsing and validation operations.

Learn More

XQJ Tutorial Part IV: Processing Query Results

In XQuery, query evaluation results in a sequence. This chapter describes how to use the XQJ XQSequence object, which represents an XQuery sequence and a cursor to iterate over the sequence.

Learn More

XQJ Tutorial Part V: Serializing Results

This chapter of the XQJ Tutorial shows you how to serialize query results as XML, and how to use HTML and XHTML output methods for results.

Learn More

XQJ Tutorial Part VI: Manipulating Static Context

An expression's static context — the default element namespace, default order for empty sequences, the base URI, and other information — can be accessed through the XQJ API. This chapter describes the static context in greater detail, and shows how to use XQJ to manipulate it.

Learn More

XQJ Tutorial Part VII: XQuery Type System

XQuery is a strongly typed language, with a type system based on XML Schema. This chapter describes how to use the XQSequenceType and XQItemType XQJ interfaces to interact with the XQuery type system.

Learn More

XQJ Tutorial Part VIII: Binding External Variables

Continuing where Part III: Querying Data from XML Files or Java XML APIs leaves off, this chapter discusses the topic of binding variables in greater detail. Need to convert a Java object in your Java application into an XDM instance? XQJ defines this mapping and glues it all together.

Learn More

XQJ Tutorial Part IX: Creating XDM Instances

XQJ offers functionality to create both XQSequence and XQItem objects, not as a result of a query execution, but rather as standalone XDM instances. Read this chapter and learn more about the flexibility of creating XDM instances outside query execution using XQJ.

Learn More

XQJ Tutorial Part X: XML Pipelines

An XML pipeline is a sequence of XML processes, also called transformations; in a pipeline, the result of one transformation is passed as input to the next one. In this chapter, you'll learn how to create a pipeline of XQueries and how to integrate XQuery with JAXP-based XML processors.

Learn More

XQJ Tutorial Part XI: Processing Large Inputs

Since XML became a standard in the late 90's, we have been taught that XML is a tree; and the most intuitive (and popular) representation of such a tree has been (and still is!) the Document Object Model (DOM). But the DOM has limitations, especially where performance and scalability are concerned. This chapter shows you how to take advantage of streaming processors, like the one available from DataDirect XQuery®.

Learn More

XQJ Tutorial Part XII: XQJ References

The XQJ Tutorial introduces a number of technologies and techniques for developing XQuery applications using XQJ. We've compiled a short list of useful resources for those who want to do more self-guided exploration on XQJ and related topics.

Learn More