XQuery Advanced Application: Developing application usage

Source: Internet
Author: User
Tags command line xpath xslt xquery

This article supporting source code

Before you start

Before discussing the XQuery sample code, let's begin by introducing how to learn this tutorial, how to install and use the attached source code (see download section).

About this tutorial

This tutorial describes how to use XQuery to develop applications and middleware. Enumerates some of the limitations of XQuery in application development and provides practical advice on how to overcome these limitations, while highlighting the advantages and disadvantages of XQuery in dealing with these issues. On this basis, a number of common programming idioms in application development are presented using a large amount of space:

Using extension functions

Unit Tests and assertions

Recursion and sorting

Higher order functions

Goal

The purpose of this tutorial is to help you learn how to use XQuery to develop applications. I will try to provide mature code that can be cut and pasted for direct use in your application development, but I hope these examples will enable you to reconsider the application of XQuery, not just query XML.

Prerequisite

This tutorial is written for developers who have some knowledge of XML technology and are somewhat interested in XSLT or Query. The programming idioms presented here are not invented by me and exist in various forms in a variety of computer languages. This reuse means that for most readers, you will see a familiar structure-albeit in an XQuery programming environment.

System Requirements

Michael Kay's Saxon XSLT and XQuery Handler SA-aware version must be installed to execute the sample code. Because a SAXON-SA version is required, you must register to get a 30-day trial period (for example, the 9.1SA version was tested during the writing process). Many sample code uses higher-order functions to take advantage of SAXON-SA proprietary extension functions (specifically, saxon:function ()).

Place all java™archive (JAR) files and license files for Saxon in the/lib directory.

The example in the run text can invoke Saxon from the command line, or use the Ant build file in the download file (which I used to test the sample code). If you use a build file, you should install the latest Apache Ant and modify the Saxon.lib.dir property to point to the/lib directory that contains the Saxon JAR. To check if Saxon is installed correctly, you can run Ant against Checksaxon and the process will complete successfully if the installation is correct. All ANT targets output the results to the/result directory.

Today's XQuery

Now let's talk about the history of XQuery and the current situation.

XQuery specification

So-called XQuery specification, I mean a set of interrelated documents:

XQuery 1.0 (an XML query language): Defines the core language

XQuery 1.0 and XPath 2.0 data models: Defines a data model that is common to XPath and XQuery

XQuery 1.0 and XPath 2.0 formal semantics: Provides a mathematical basis

XQuery 1.0 and XPath 2.0 functions and operators: Defines functions that are common to XPath and XQuery

XSLT 2.0 and XQuery1.0 serialization: defines how to construct and output XML from XQuery

Others think XML Query use case documentation is also useful, and it presents a variety of scenarios and corresponding XQuery solutions. There are also some specifications and drafts that provide other features, such as updating XML and Full-text search.

"So many specs?" "It's not just you who have this idea, it's hard to understand why the Working Group has so many interrelated documents." If it's complicated, then I can't disagree, but I do wonder why XSLT 1.0 (see Resources) can be done with a specification (or two-because there is another XPath 1.0 specification).

During the definition of the XQuery1.0 specification, there are several problems that always follow XQuery. Many of these very serious restrictions have made (at the time) that I am sure will hinder the development of XQuery (after a year of intensive development, most of which ultimately proved irrelevant). Admitting your mistakes is a good way to learn, so I think we can look at these problems again.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.