XQuery from the Experts: A Guide to the W3C XML Query Language Be the First to Write a Review and tell the world about this title!People who purchase this book frequently purchase: Books on similar topics, in best-seller order:Books from the same publisher, in best-seller order:
Extensible Markup Language (XML) is everywhere. In an astonishingly short period
of time, XML has worked itself into the nooks and crannies of corporate IT departments,
academic research institutions, and small-shop programming operations everywhere.
As one of the authors of this book points out, XML now encodes a bewildering
array of datatypes scattered across a large number of diverse application domains.
Where there's information, there are people who are going to need to query
that information. Happily, XQuery has come along to provide a powerful and standardized
way of searching through all that XML-encapsulated data. Going beyond Google,
XQuery provides a flexible and easy-to-use mechanism for querying not only content,
but structure as well. Drawing from XSLT, XQuery doesn't content itself with
simply providing a query capability; it does transformations too. I believe
that it will increasingly replace XSLT in a number of application areas (though
XSLT aficionados needn't fear—there are plenty of things to do for both
technologies). Most interestingly, some of the data that XQuery will manipulate
won't even have started life as XML: A large portion of the data that XQuery
deals with will have started life in the form of rows and columns in corporate
relational databases.
This Book
Most technical books are either tutorials or reference works. You turn to the
former if you're looking for a gentle introduction to a new subject; you look
to the latter if you already know something about the subject and want a minimum
of hand-holding while you seek out the information you need. This book is unusual
in that it shares some of the characteristics of each. It consists of a series
of technical essays and perspectives, some of them tutorial-like, on various
facets of XQuery from members of the World Wide Web Consortium's (W3C) Query
working group, the standards body that has been hard at work creating and crafting
the formal definition of the language since the fall of 1999. Their intimate
knowledge sheds a lot of light on a technical topic that some find daunting,
given the weight and density of the formal spec.
Members of the working group would probably be embarrassed to hear themselves
referred to here as "experts," as the title implies, but that's what they are.
Nobody knows the material better than this group—after all, they created
it! In this case you could say (pun intended) that they "wrote the book." And
not just the one you're reading: They also wrote most of the specification itself,
since nearly every one of the authors is also an editor of one or more of the
numerous documents that comprise the formal specification.
In addition to being intimately involved in the creation of XQuery and the
specification documents that define it (twelve at this point and counting),
the credentials shared by the collective authorship of this book is impressive.
They are researchers and theoreticians, software architects, product managers,
educators, and database implementers. They are the designers of no less than
six influential computer languages, including Haskell, Quilt, XML-QL, YATL,
XQL, and SQL. Their views on query languages and XML are helping to shape the
technology strategies of some of the most influential computer companies in
the world. All in all, an impressive group! The "Contributors" section gives
the bona fides of all our experts. It's worth perusing.
This book provides an opportunity for these people to write individually about
the XQuery topics they know best and about which they are most passionate. It
allows each of them to write with a personal voice and perspective in a way
that's not possible within the carefully and consensually crafted framework
of a formal standards specification.
Who Should Read This Book?
You should read this book if you're interested in XQuery—-a statement
that describes numerous technophiles these days. The members of two programming
disciplines in particular, however, will find this volume especially valuable.
XSLT developers will be interested in these essays. As noted above, XQuery shares
a number of capabilities with XSLT and is likely to replace it in some areas.
Michael Kay's chapter on "XQuery, XPath, and XSLT" (Chapter 3) examines the
commonalities and differences between the two languages in some detail.
This book will also interest those who are corporately or otherwise involved
with SQL and relational databases. XQuery has often been called SQL for XML,
and that's no accident, given that several members of the working group come
from a relational database background. XQuery was designed from the ground up
to work with relational data. Two of the chapters in Part IV, "Databases," examine
the connections between XQuery and relational data.
Whatever your specific background, you should be comfortable and familiar with
XML basics to benefit most fully from this book. You'll do best if you have
some prior exposure to XQuery, although it needn't be extensive. At a minimum,
the book assumes that you understand the fundamentals of XPath and know what
a location path is. Jonathan Robie's introductory guided tour provides a good
overview of XQuery for those who aren't already familiar with the technology.
Organization and Roadmap
Your approach to this material will depend on your specific experience and
interests. Here's a quick roadmap to the four parts of the book and a look at
the individual chapters to help you figure out where to dive in first.
Part I: Basics
Part II: Background
Part III: Formal Underpinnings
Part IV: Databases
Part I: Basics
Jonathan Robie's "XQuery: A Guided Tour" provides a good starting point if
you're new or relatively new to XQuery. Its easy, tutorial-like style invites
you to read it straight through. Jonathan provides a compact and convenient
reference to XQuery's key features that newcomers and experts alike can return
to periodically for a quick refresher on the basics while working through the
detail in the other chapters. Jonathan's coverage is extensive; most of the
entries in the glossary (a useful resource when you're stumbling across new
terminology) are introduced in this chapter. (Note that glossary entries are
bolded the first time they appear within the text.)
Part II: Background
The two chapters in Part II provide historical context and a detailed rationale
for many of the complex technical decisions the Query working group has had
to make as the language has evolved.
As Don Chamberlin explains in Chapter 2, "Influences on the Design of XQuery,"
the process of designing XQuery has been one of resolving the tensions between
conflicting goals, and his chapter provides a historical and technical description
of that dialectic in action. This chapter also places XQuery in the context
of the other related languages and standards with which it coexists. The second
half of the chapter deals in cogent detail with the intricacies of what Don
calls "watershed issues": eight complex and often controversial issues that
have had a major impact on the design of the language. Don goes a long way to
teasing apart the complexities.
As Michael Kay notes in Chapter 3, "XQuery, XPath, and XSLT," the fact that
both these languages share a common data model, as well as a common sublanguage
in XPath, is a major achievement of the W3C. His chapter explores that commonality
and the overlap in functionality between the two languages, as well as their
differences. This chapter describes where each language might be employed to
best advantage. Mike addresses some of the same issues discussed by Don Chamberlin
in the previous chapter but from the particular perspectives of XPath and XSLT.
Part III: Formal Underpinnings
Both chapters in Part III were written by Mary Fernandez, Jerome Simeon, and
Philip Wadler. Chapter 4, "Static Typing in XQuery," is a gentle tutorial that
explores the ramifications of static typing in a language dealing with XML data.
Despite the term formal in the title of this part, this chapter fits naturally
here because it provides such a great lead-in to the chapter on the formal semantics—the
topic isn't difficult or particularly heavy. Static typing is important to XQuery
developers because it helps to guarantee program correctness, and it helps significantly
to speed up the development cycle, as this chapter attests. Users need to understand
the concept of static typing in order to better understand the error messages
returned by the query system they're working with.
Chapter 5, "Introduction to the Formal Semantics," is a tutorial-like introduction
to the formal semantics, the formal mathematical system on which XQuery is built.
This is the most challenging technical component of XQuery. This chapter should
appeal to implementers, language theoreticians, and those just terminally curious
about this aspect of the language. They will find here a much less daunting
approach to the formal semantics than that provided by the specification.
Part IV: Databases
Most major relational database vendors already have or will shortly provide
support for XQuery as a front end for relational data, and interest in XQuery
from this market sector was one of the driving forces behind its development.
Chapters 6 and 7 deal with the topic of XQuery and relational data. The authors
collaborated on the content so that the chapters would fit seamlessly together.
The last chapter in this part describes the features of what its author refers
to as an XML database management system.
XQuery was designed to query XML, and using it to query and pull data out of
relational databases that store information in tabular format poses a number
of interesting challenges. Denise Draper explores these issues in "Mapping between
XML and Relational Data."
Michael Rys's chapter, "Integrating XQuery and Relational Database Systems,"
builds on the foundation laid in Chapter 6. Michael shows two methods of accessing
XML stored in a relational database. One approach uses the XML datatype to store
XML into the database as an LOB (large object) and accesses that data using
a combination of both XQuery and SQL. He also describes a so-called "top-level
XQuery" approach that obviates the need to use SQL altogether.
Jim Tivy's concluding chapter, "A Native XML DBMS," rounds out the offerings
in this part. Jim describes the key features of what he calls an XML database
management system and explores what that means. He looks at the use of the XQuery
data model in that context and explores other XML DBMS features such as command
languages and APIs, drawing on his experience with XStreamDB (his own native
XML database product), Tamino, and the XML:DB Initiative.
Table of Contents
Preface.
Contributors.
Acknowledgments.
I. BASICS.
1. XQuery: A Guided Tour.
Sample Data: A Bibliography.
Data Model.
Literals and Comments.
Input Functions.
Locating Nodes: Path Expressions.
Creating Nodes: Element, Attribute, and Document
Constructors.
Combining and Restructuring Nodes.
FLWOR Expressions.
Quantifiers.
Conditional Expressions.
Operators.
Arithmetic Operators.
Comparison Operators.
Sequence Operators.
Built-in Functions.
User-Defined Functions.
Variable Definitions.
Library Modules.
External Functions and Variables.
Types in XQuery.
Introduction to XQuery Types.
Schemas and Types.
Sequence Types.
Working with Types.
Summary.
II. BACKGROUND.
2. Influences on the Design of XQuery.
The Need for an XML Query Language.
Basic Principles.
The Query Data Model.
Related Languages and Standards.
XML and Namespaces.
XML Schema.
XPath.
Other Query Languages.
Watershed Issues.
Issue 1: Handling of Untyped Data.
Issue 2: Unknown and Inapplicable Data.
Issue 3: What Is a Type?
Issue 4: Element Constructors.
Issue 5: Static Typing.
Issue 6: Function Resolution.
Issue 7: Error Handling.
Issue 8: Ordering Operators.
Conclusion.
3. XQuery, XPath, and XSLT.
XSLT: A Quick Introduction.
XPath 1.0.
Why Was a New Query Language Needed?
Differing Requirements.
Differing Cultures.
Convergence: XPath 2.0.
XSLT and XQuery Compared.
XML-Based Syntax.
Semantics of Element Construction.
Functions and Named Templates.
FLWOR Expressions.
Template Rules.
Axes.
Type Strictness.
Optimization Techniques.
Where Does the Time Go?
Internal Coding Efficiency.
Pipelining and Lazy Evaluation.
Expression Rewriting.
Using Type Information.
Conclusion.
III. FORMAL UNDERPINNINGS.
4. Static Typing in XQuery.
The Benefits of Static Typing.
An XQuery Programming Scenario.
Debugging.
Validation.
Static Typing.
Getting Started with Types.
XML Schema and XQuery Types.
Values.
Sequence Types.
Schema Import.
Relating Values and Types.
Literals and Operators.
Variables.
Functions.
Conditionals.
Path Expressions.
Predicates.
FLWOR Expressions.
Element Construction.
Validation Context.
Validation Mode.
A Final Example: Grouping.
Conclusions.
5. Introduction to the Formal Semantics.
The Benefits of a Formal Semantics.
Getting Started with the Formal Semantics.
Dynamic Semantics.
Environments.
Matching Values and Types.
Errors.
Static Semantics.
Type Soundness.
Evaluation Order.
Normalization.
Finishing Getting Started.
Learning More about XQuery.
Values and Types.
Matching and Subtyping.
FLWOR Expressions.
Path Expressions.
Implicit Coercions and Function Calls.
Node Identity and Element Constructors.
The Forest through the Trees.
IV. DATABASES.
6. Mapping between XML and Relational Data.
Framing the Problem.
Processing Models.
Application Types.
Sources of XML Data.
LOB or Compose?
Composition Techniques: Common Concepts.
Generation of XML Structure through Hierarchical
Joins.
Generation of XML Structure through Hierarchical
Grouping.
Composition Techniques: Examples.
Default Mapping.
Extended SQL.
Annotated XML Template.
Additional Mapping Languages.
Shredding.
Creation of the Database.
Adding Extra Information to the Composition.
Inlining and Consolidation.
Support of Full XML.
Schema-Independent Representation.
Implementation Concepts.
Emitting XML Documents.
Querying and Updating XML Documents.
Conclusion.
7. Integrating XQuery and Relational Database
Systems.
Getting Started.
Relational Storage of XML: The XML Type.
Logical Models for the XML Datatype.
Physical Models for the XML Datatype.
Encodings and Collations.
Typing an XML Datatype.
Other Aspects of the XML Datatype.
Integrating XQuery and SQL: Querying XML Datatypes.
XQuery Functionality in SQL.
Augmenting the XQuery Static Context.
Providing Access to SQL Data inside XQuery.
Adding XQuery Function Libraries.
A Note on the XQuery Data Modification Language.
Physical Mappings of XQuery.
Issues of Combining SQL, XML Datatype, and XQuery.
Top-Level XQuery.
XML Document (Fragment) Collections.
XML Views over Relational Data.
Conclusion and Issues.
8. A Native XML DBMS.
What Is XML Data?
XML as Text.
XML Data Model.
Interfaces to a Native XML Database.
Interoperability.
Data-Definition Interfaces.
Update Interfaces.
Database Configuration Interfaces.
A Database Command Language.
Collections and Storage.
XQuery Client APIs.
Full-Text Search in a Native XML Database.
Sample Applications.
Invoice Archive.
A Content Management Application.
Conclusion.
References.
Glossary.
Index.
|