Skip to Content
XQuery, 2nd Edition
book

XQuery, 2nd Edition

by Priscilla Walmsley
December 2015
Intermediate to advanced
762 pages
19h 13m
English
O'Reilly Media, Inc.
Content preview from XQuery, 2nd Edition

Chapter 21. Working with Qualified Names, URIs, and IDs

This chapter describes the functions and constructors that act on namespace-qualified names, Uniform Resource Identifiers (URIs), and IDs. Each of these types has unique properties and complexities that sets it apart from simple strings.

Working with Qualified Names

The type xs:QName is used to represent qualified names in XQuery. An xs:QName value has three parts: a namespace, a local part, and an associated prefix. The namespace and the prefix are optional. If a QName does not have a namespace associated with it, it is considered to be in “no namespace.”

A prefix may be used to represent a namespace in a qualified name, for example, in an XML document. The prefix is bound to a namespace by using a namespace declaration. The prefix itself has no meaning; it is just a placeholder. Two QNames that have the same local part and namespace are equivalent, regardless of prefix. However, the XQuery processor does keep track of a QName’s prefix. This simplifies certain processes like serializing QNames and casting them to strings.

Most query writers who are working with qualified names are working with the names of elements and attributes. (It is also possible for a qualified name to appear as element content or as an attribute value, but this is less common.) You may want to retrieve all or part of a name if, for example, you want to test to see if it is a particular value, or you want to include the name in the query results. You may ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

XQuery

XQuery

Priscilla Walmsley
XSLT

XSLT

Doug Tidwell
Learning XSLT

Learning XSLT

Michael Fitzgerald

Publisher Resources

ISBN: 9781491915080Purchase bookErrata Page