[ Part III of The XML seminar ]

19
[ [ Part III of The XML seminar Part III of The XML seminar ] ] Presenter: Xiaoge Presenter: Xiaoge ng Zhao ng Zhao A Introduction of XQL

description

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 - PowerPoint PPT Presentation

Transcript of [ Part III of The XML seminar ]

Page 1: [  Part III of The XML seminar  ]

[ [ Part III of The XML seminar Part III of The XML seminar ]]

Presenter: Xiaogeng ZhaoPresenter: Xiaogeng Zhao

A Introduction of XQLA Introduction of XQL

Page 2: [  Part III of The XML seminar  ]

I. What is XQL?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

provides a concise, understandable notation for

pointing to specific elements and for searching for

nodes with particular characteristics.

Page 3: [  Part III of The XML seminar  ]

II. XQL FeaturesII. 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.

Page 4: [  Part III of The XML seminar  ]

III. The XML Data ModelIII. The XML Data Model

• A document is an ordered, labeled tree, with nodes to represent the:

• document entity

• elements

• attributes

• processing instructions

• comments

Page 5: [  Part III of The XML seminar  ]

The XML Data Model (Cont.)The XML Data Model (Cont.)

The Tree Structure ( XQL uses the tree structure for navigation )

• Hierarchy

• Sequence

• Position

Page 6: [  Part III of The XML seminar  ]

III. SQL vs. XQLIII. SQL vs. XQL• 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.

• 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.

Page 7: [  Part III of The XML seminar  ]

IV. Basics of XQL

• Context

• start context

• Context operators

( /, //, [] )

Page 8: [  Part III of The XML seminar  ]

Search Context

• XML Document

Page 9: [  Part III of The XML seminar  ]

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.

Page 10: [  Part III of The XML seminar  ]

Basics of XQL

• The child operator ("/") indicates hierarchy.

• XQL query :

book/front/author

• Result :

returns <author> elements that are children of <front> elements

Page 11: [  Part III of The XML seminar  ]

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

Page 12: [  Part III of The XML seminar  ]

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

Page 13: [  Part III of The XML seminar  ]

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:

Page 14: [  Part III of The XML seminar  ]

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

Page 15: [  Part III of The XML seminar  ]

Basics of XQL

• The filter operator ("[ ]") 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"

Page 16: [  Part III of The XML seminar  ]

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

Page 17: [  Part III of The XML seminar  ]

Advance XQL

• Join

• Comprehension

•  Methods…

Page 18: [  Part III of The XML seminar  ]

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

Page 19: [  Part III of The XML seminar  ]

END of PART III