slanted W3C logo
Cover page images (keys)

XML Query: what is it, how do I use it and why?

Liam Quin

XML Query: what is it, how do I use it and why?

Liam Quin, W3C

What Is It?

A Query Language for XML

Integration Language 2

xquery engine

Integration Language

Syntactic extension to XPath 2

Standardised Middleware

Before XQuery, to connect between Web servers, multiple databases, files, applications, you used...

Standardised Middleware [2]

PROPRIETARY SOFTWARE

Standardised Middleware [3]

PROPRIETARY LANGUAGES

Standardised Middleware [4]

Standardised Middleware [5]

IT’S BETTER.

How do I use it?

Architecture [1]

using XQuery with a Web Server

Architecture [2]

copying databases with XQuery/Update

Architecture [3]

Making RDF with XQuery

Architecture [4]

From XML to Printed Page

Architecture [6]

Summary:

XML Query is a good choice for integrating information from a wide range of sources and producing any XML-based vocabulary.

XML Implementations tend to be optimised for handling multiple input sources, and often use indexes for efficiency.

Architecture [7]

IT’S FAST.

Implementations [1]

The XML Query Home Page lists well over forty implementations of XML Query

Implementations [2]

Examples [1]

(: find shirts that fit me :)
let $g := doc("garments.xml"),
for $shirt in $g/garments/item[type = "shirt"]
where
    $shirt/collar = 15
    and not(contains($shirt/style, "stripe"))
return
    <candidate>$shirt/colour</candidate>

Examples [2]

(: find wallpaper images of the Tower of London :)
let $images := doc("jdbc:mysql:localhost:localuser:images"),
	$kw := doc("rdf.xml")
for $item in $rdf/triplets[relation = "locname"]
where
    $item/value = "Tower of London"
    and some $image in $images satisfies (
	$image/uri = $item/uri
	and $image/width = 1024 and $image/height = 768
    )
return
    $item/uri

Examples [2b]

(: find wallpaper images of the Tower of London :)
for $item in $rdf/triplets[relation = "locname"]
where
    $item/value = "Tower of London"
    and some $image in $images satisfies (
	ii:uri($image) = rdf:uri($item)
	and ii:width($image) = 1024
	and ii:height($image) = 768
    )
return
    rdf:uri($item)

Examples [2c]

declare namespace ii = "http://www.example.org/imageinfo/1.6";
declare function ii:width($image as element databaserow)
    as xsi:integer?
{
    return $image/width
};

Why should I use XQuery?

Why should I use XQuery? [2]

IT’S COOLER.

Query Status

Why should I use XQuery? [2]

QUESTIONS?

Questions/Discussion

the scholar looks up from writing

About

Liam Quin,
XML Activity Lead
W3C
liam@w3.org