Professional Documents
Culture Documents
Querying XML Documents With Xquery
Querying XML Documents With Xquery
databases
Querying XML Documents
An ambitious application of XML documents aims at
generalizing the traditional relational model of databases.
The actual generalization is fairly straightforward, as we
shall see.
The main challenge lies extending the query language
correspondingly, thus inventing an XML analog of the
popular SQL query language.
There are several reasons why a merger of XML and
databases is attractive. For XML developers, the creation of
XML language is akin to data modeling in databases, only
with fewer constraints on the data format.
There is an immediate desire to extract information directly
from these richer models.
Querying XML Documents
In the database community, there has been a long quest
for a richer data model to replace the plain relational
tables, there has been a long reached.
Some of the earlier suggestions have been hierarchical
databases, object-oriented databases and multi-
dimensional databases that all seek in different ways to
extend the relational data model.
XML us tempting alternative, since we have previously seen
that XML may describe both data-oriented and document-
oriented information. Thus, it directly offers a richer data
model that includes many aspects of the previous
proposals; however, XML comes with a ready-made
consensus.
Querying XML Documents
Another strategic advantage for the database community is
that if XML is the frame of the World Wide Web and XML
becomes the future of databases, then in the World Wide
Web will simply become one gigantic database.
Relationship to XSLT
XQuery and XSLT seem to share many ambitions, as they
both are domain-specific languages for combining and
transforming XML data from multiple sources. They are vastly
different in design. Partly fro historical reasons. While Xquery
is designed from scratch with inspiration from SQL.
Querying XML Documents
XSLT is an intellectual descendant of CSS and has developed
for a long time. Technically, they actually have different
fortes. XSLT is exceedingly good for defining complicated
recursive traversals and transformation to arbitrary depths
of XML documents.
Where XQuery must use explicit recursion of user-defined
functions. Conversely, Xquery has more the flovor of
database programming language and allows simple solutions
for simple problems, where XSLT may be more verbose.
It is around that XSLT is soon deprecated and sholud be
replaced by Xquery. Apart from the huge amount of legacy
code to consider, XSLY is, however, still the simplest choice
for many applications.
Querying XML Documents
Alsp, XSLT already has several very efficient
implementations, while the general design of XQuery
seems to pose more of a challenge. Thus, both languages
will most likely be around for a while yet.
When raw expressive power is considered, XQuery and
XSLT are surprisingly evenly matched, as shown in section
6.6. however, while the languages may emulate each
other. They each display a lack of elegance when doing so
emphasizing that domain specific syntax is a valuable
asset.