Skip to main content


developerWorks  >  XML | Java technology  >

Advanced XQuery: Creating custom functions

Put software development best practices into XQuery expressions

developerWorks

Level: Intermediate

Brian M. Carey (careyb@triangleinformationsolutions.com), Information Systems Consultant, Triangle Information Solutions

11 Nov 2008

Register now or sign in using your IBM ID and password.

XQuery functions enable you to define common expressions once and reuse them frequently. The end result is tighter, more robust code that is easier to maintain. Using XQuery API for Java (XQJ), this tutorial demonstrates an implementation of XQuery functions within a Java™ environment.

In this tutorial

XQuery has quickly become the industry standard for querying XML documents. However, anyone who works with complex XML documents inevitably finds that detailed XQuery expressions can quickly become awkward and hard to understand. Further, some XQuery expressions are repeated within a variety of processing routines. This creates redundant expressions and adds complexity to system maintenance.

Enter XQuery functions. They provide a powerful and often overlooked means of processing XML with three distinct advantages: reusability, easier readability, and a separation of concerns.

This tutorial covers exactly what XQuery functions are, their advantages, and how to implement them. It guides you through the implementation of an XQuery function within a simulated eCommerce environment using a Java Runtime Environment (JRE) and DataDirect's XQJ package. At the end of this tutorial, you will have a working example of an XQuery function and its applicability to a business requirement.


Objectives

  • Cover exactly what XQuery functions are, their advantages, and how to implement them.

  • Implement an XQuery function within a simulated eCommerce environment using a Java Runtime Environment (JRE) and DataDirect's XQJ package.

  • Create a working example of an XQuery function and its applicability to a business requirement.

Prerequisites

This tutorial is written for people who already have an understanding of XML, the Java programming language, and XQuery. For more information about learning XML, Java programming, or XQuery, see the tutorial resources.


System requirements

You will need JavaScript enabled in your browser.

To run the examples in this tutorial, you need to have the following installed:

  • Java Standard Edition platform (Currently, the latest version is 1.6, which is the version recommended for this tutorial.)
  • DataDirect XQuery (The libraries for XQJ must be in the classpath of your Java environment. They will be referenced by the Java class that you develop in this tutorial.)

For more information about these products, see the tutorial resources. You might want to download the sample code provided with this tutorial before you start.



Duration

1 hour





Formats

html, pdf


Share this....

digg Digg this story del.icio.us del.icio.us Slashdot Slashdot it!


Back to top


Document options

Document options requiring JavaScript are not displayed


My developerWorks needs you!

Connect to your technical community