xquery how to handle databases with the xml standard?
DESCRIPTION
XQuery How to handle databases with the XML standard?. Peter van Keeken Industrial trainee, Evitech 4 th period 2002. What is XQuery?. XQuery is a data query language for XML designed by W3C. XQuery is designed to be broadly applicable across all types of XML data sources - PowerPoint PPT PresentationTRANSCRIPT
XQuery
How to handle databases with the XML standard?
Peter van Keeken
Industrial trainee, Evitech
4th period 2002
What is XQuery?
XQuery is a data query language for
XML designed by W3C.
XQuery is designed to be broadly applicable across all types of XML data sources
(eg. Databases).
XQuery history
XQuery is derived from Quilt• an XML query language • which borrowed features from languages like:
– XPath 1.0 – XQL (XML Query Language)– XML-QL (a query language for XML)– SQL (Structured Query Language)– OQL (ODMG, Object Database Standard)
XQuery specifications:
• Able to query databases and data from (XML) documents
• XQuery is a data model describing how a XQuery processor should process an XML document or datasource that is available to an XQuery processor.
• XQuery is also based on:1. XML Schema2. XPath (version 2.0)
• a human-readable syntax and an XML-based syntax is required
More practical decription:
• Allows joins between XML documents• Allows sorting and grouping• Language is SQL like but works on
trees rather then relational tables
An simple example:
• You have for instance the next list of recipes in an XML Document: recipes.xml
• Example XQuery:FOR $t IN document (“recipes.xml”) // title
RETURN $t
• The result:The query will return all the titles
of the recipes in the file.
Another example:• A more complex query based on the same resource:
recipes.xml
• Example XQuery:FOR $i IN distinct(document("recipes.xml") //ingredient/@name)
RETURN <ingredient name={$i}>
{ FOR $r IN document("recipes.xml")//recipe
WHERE $r//ingredient[@name=$i] RETURN $r/title
}
</ingredient>
• The result:The query will return for each ingredient,
the recipes that it is used in.
The Good about XQuery
• Can store document or data style XML• Tremendous flexibility• Complement RDBMS with XML mapping
solutions• Performance can be very good
The Bad about XQuery
• Standard is still in development• Techniques are unfamiliar to people• Not good at transaction processing• Some expected database practices are still
unsupported• Interoperability between products is minimal
Resources:
WWW:• www.w3.org/TR/xquery/• people.cs.uct.ac.za/~agelderb/hons/coursXMLAarhus.pdf
Book (for XML Schemas):D. Hunter, Beginning XML, 2nd Edition, Wrox P2P serie
THE END
Questions?