190 likes | 302 Views
A Introduction of XQL. [ Part III of The XML seminar ]. Presenter: Xiaogeng Zhao. I. What is XQL?. XML Query Language ( XQL ) It is a notation for addressing and filtering the elements and text of XML documents. XQL is a natural extension to the XSL pattern syntax . It
E N D
A Introduction of XQL [ Part III of The XML seminar ] Presenter: Xiaogeng Zhao
I. What is XQL? XML Query Language ( XQL ) It is a notation for addressing and filtering the elements and text of XML documents. XQL is a natural extension to the XSLpattern syntax. It provides a concise, understandable notation for pointing to specific elements and for searching for nodes with particular characteristics.
II. XQL Features • XQL is a query language designed specifically for XML. • In XQL it is possible to combine information from heterogeneous data sources in powerful ways. • XQL specification does not indicate the output format.
III. The XML Data Model • A document is an ordered, labeled tree, with nodes to represent the: • document entity • elements • attributes • processing instructions • comments
The XML Data Model (Cont.) The Tree Structure ( XQL uses the tree structure for navigation) • Hierarchy • Sequence • Position
III. SQL vs. XQL • XQL • 1) The database is a set of one or more XML documents. • 2) Queries are done in XQL, a query language that uses the structure of XML documents as a basic model. • 3) A query is given a list of input nodes from one or more documents. • 4) The result of a query is a list of XML document nodes, which may serve as the basis for further queries. • SQL 1) The database is a set of tables. 2) Queries are done in SQL, a query language that uses the structure of tables as a basic model. 3) The FROM clause determines the tables which are examined by the query. 4) The result of a query is a table containing a set of rows; this table may serve as the basis for further queries.
IV. Basics of XQL • Context • start context • Context operators ( /, //, [] )
Search Context • XML Document
Basics of XQL • A simple string is interpreted as an element name. • XQL query : book • Result : return all <book> elements from the current search context.
Basics of XQL • The child operator ("/") indicates hierarchy. • XQL query : book/front/author • Result : returns <author> elements that are children of <front> elements
Basics of XQL • The root of a document may be indicated by a leading "/" operator. • XQL query : /store/book/front/author • Result : Starting the navigation from the root: returns <author> elements that are children of <front> elements
Basics of XQL • The content of an element or the value of an attribute may be specified using the equals operator ("="). • XQL query : book/front/author=‘Danny’ • Result : return all authors with the name ”Danny" that are children of the <front> element
Basics of XQL • Attribute names begin with "@".They are treated as children of the elements to which they belong. • XQL query : book/front/author/address/@type • Result : Finding values of the “type” attribute in addresses of authors:
Basics of XQL • The descendant operator ("//") indicates any number of intervening levels. When the descendant operator is found at the start of a path, it means all nodes descended from the document. • XQL query : //address • Result : This query will find any address in the document
Basics of XQL • The filteroperator ("[ ]") filters the set of nodes to its left, based on the conditions inside the brackets. • XQL query : book/front/author/address[@type='email'] • Result : This query returns addresses; each of these addresses must have an attribute called "type" with the value "email"
Basics of XQL • Multiple conditions may be combined using Boolean operators. • XQL query : book/front/author=‘Tom'[@gender='male' and @description =‘good guy'] • Result : • Return the author element with the name of Tom whose gender is male and is a good guy
Advance XQL • Join • Comprehension • Methods…
Other XML Query Languages • XML-QL • Lorel • YATL XQL is A Query Language for ”Documents” while XML-QL Lorel and YATL are more ”Database” oriented