XML - QL A Query Language for XML

Preview:

DESCRIPTION

XML - QL A Query Language for XML. Version 0.6. Outline. Introduction Examples in XML-QL A Data Model for XML Advanced Examples in XML-QL Extensions and Open Issues Summary. Why do we need a query language ?. XML standard doesn't address: - PowerPoint PPT Presentation

Citation preview

XML - QLXML - QLA Query Language for A Query Language for

XMLXMLVersion 0.6

04/2000 XML-QL 2

Outline

Introduction

Examples in XML-QL

A Data Model for XML

Advanced Examples in XML-QL

Extensions and Open Issues

Summary

04/2000 XML-QL 3

Why do we need a query language ?

XML standard doesn't address: Extraction : How will data be extracted from large XML

documents?

Transformation : How will XML data be exchanged between user communities using different but related

DTD's?

Integration : How will XML data from multiple XML sources be integrated?

Conversion of data between relational or OO to XML

04/2000 XML-QL 4

What Does XML-QL do ?

Extraction - of data pieces from XML documents

Transformation - Map XML data between different DTDs

Integration/Combination of XML data from different sources

04/2000 XML-QL 5

How will data be extracted from large XML documents?

04/2000 XML-QL 6

Data Transformation

How will XML data be exchanged between user communities using different but related DTD's?

04/2000 XML-QL 7

Data Integration

04/2000 XML-QL 8

XML - QL “Relational complete”

Can expression selection, join etc. Nested queries

Precise semantic To support reasoning

XML - specific features Regular-path expressions & tag variables No DTD required, exploit when available

Rewritability Preserve order and Association

Ordering of elements, grouping of subelements Server-side processing

Prototype implementation in Java.

04/2000 XML-QL 9

Requirements for a query language for XML

Selection and extraction Preserve structure. Reduction Restructuring Join

(will be shown in the first part)

04/2000 XML-QL 10

Requirements for a query language for XML

Tag Variables Regular path expressions Transforming XML data between DTDs No schema required Indexing Sorting.

(will be shown in the advanced part)

04/2000 XML-QL 11

Outline Introduction

Examples in XML-QL

A Data Model for XML

Advanced Examples in XML-QL

Extensions and Open Issues

Summary

04/2000 XML-QL 12

Class Number – cs 401Class Number – cs 401

Class- web and xmlClass- web and xml

Instructor – Sanjay MadriaInstructor – Sanjay Madria

Lesson Title - XML-QLLesson Title - XML-QL

04/2000 XML-QL 13

BIB . DTD

<!ELEMENT book (author+, title, publisher)>

<!ATTLIST book year CDATA>

<!ELEMENT article (author+, title, year?, (shortversion|longversion))>

<!ATTLIST article type CDATA>

<!ELEMENT publisher (name, address)>

<!ELEMENT author (firstname?, lastname)>

04/2000 XML-QL 14

Basic Examples: Selection/Extraction

Find all the names of the authors whose publisher is

Addison-Wesley:

WHERE <book>

<publisher><name> Addison-Wesley </name></publisher>

<title> $t </title>

<author> $a </author>

</book> IN "www.a.b.c/bib.xml"

CONSTRUCT $a

04/2000 XML-QL 15

Basic Examples, syntax (cont)

The use of </> instead of </XXX>:

WHERE <book>

<publisher><name> Addison-Wesley </></>

<title> $t </>

<author> $a </>

</> IN "www.a.b.c/bib.xml"

CONSTRUCT $a

04/2000 XML-QL 16

Result of first query:

The output is in XML form:

<lastname> Date </lastname>

<lastname> Darwen </lastname>

<lastname> Date </lastname>

04/2000 XML-QL 17

Constructing new XML data:Reduction & Restructre

WHERE <book>

<publisher> <name> Addison-Wesley </></>

<title> $t </>

<author> $a </>

</> IN "www.a.b.c/bib.xml"

CONSTRUCT <result>

<author> $a </>

<title> $t </>

</>

04/2000 XML-QL 18

XML-QL Example Data<bib> <book year=“1995> <title> An Introduction to DB Systems </title>

<author> <lastname> Date </lastname></author>

<publisher><name> Addison-Wesley</name> </publisher>

</book><book year=“1995>

<title> Foundations for OR Databases </title><author> <lastname> Date

</lastname></author> <author> <lastname> Darwen

</lastname></author> <publisher><name> Addison-Wesley</name>

</publisher></book>

</bib>

04/2000 XML-QL 19

Constructing new XML data: (result)

<result>

<author> <lastname> Date </lastname> </author>

<title> An Introduction to DB Systems </title>

</result>

<result>

<author> <lastname> Date </lastname> </author>

<title> Foundation for OR Databases</title>

</result>

<result>

<author> <lastname> Darwen </lastname> </author>

<title> Foundation for Object/Relational Databases: The Third Manifesto </title>

</result>

04/2000 XML-QL 20

Grouping with Nested Queries: Preserve structure

WHERE <book> $p <book> IN "www.a.b.c/bib.xml” ,

<publisher> <name>Addison-Wesley </> </> IN $p ,

<title> $t </> IN $p

CONSTRUCT <result>

<title> $t </>

WHERE <author> $a </> IN $p

CONSTRUCT <author> $a </>

</>

04/2000 XML-QL 21

Reduction

Where <book> <publisher> <name>

Addition-wesley</> </>

<title>$t </> Element_As $x

<author> $a</> Element_As $y

</> </> IN www.a.b.c/bib/xml

Construct <result> $x $y </>

04/2000 XML-QL 22

Grouping with Nested Queries:Preserve structure

WHERE <book>

<publisher> <name>Addison-Wesley</> </>

<title> $t </>

</> CONTENT_AS $p IN "www.a.b.c/bib.xml”

CONSTRUCT <result>

<title> $t </>

WHERE <author> $a </> IN $p

CONSTRUCT <author> $a </>

</>

04/2000 XML-QL 23

Grouping with Nested Queries:(result)

<result>

<title> An Introduction to Database Systems </title>

<author> <lastname> Date </lastname> </author>

</result>

<result>

<title> Foundation for Object/Relational Databases: The Third Manifesto </title>

<author> <lastname> Date </lastname> </author>

<author> <lastname> Darwen </lastname> </author>

</result>

04/2000 XML-QL 24

Joining element by values:WHERE <article>

<author>

<firstname> $fn </> -- firstname $f

<lastname> $ln </> -- firstname $l

</>

</> CONTENT_AS $a IN "www.a.b.c/bib.xml”,

<book year = $y >

<author>

<firstname> $fn </> -- join the same firstname $f

<lastname> $ln </> -- join the same lastname $l

</>

</> IN "www.a.b.c/bib.xml”,

$y > 1995

CONSTRUCT <article> $a </>

04/2000 XML-QL 25

ELEMENT_AS Vs. CONTENT_AS:

WHERE <article>

<author>

<firstname> $fn </> -- firstname $fn

<lastname> $ln </> -- firstname $ln

</>

</> ELEMENT_AS $a IN "www.a.b.c/bib.xml”,

CONSTRUCT $a -- No need for <article> …. </>

04/2000 XML-QL 26

Outline Introduction

Examples in XML-QL

A Data Model for XML

Advanced Examples in XML-QL

Extensions and Open Issues

Summary

04/2000 XML-QL 27

A data model for XML

XML : data format syntaxQuery operations assume data modelXML Graph

Directed, Labeled graph Element tags on edges Attribute values on nodes Each node is represented by OID (unique string) Unordered & ordered models Leaves labeled with values

04/2000 XML-QL 28

XML graph for example XML book elements

(year=“1995”)

book book

titleauthor

publisher

title author

author

nameAn introduction …

Addison-Wesley

Addison-Wesley

Foundations for ...

name lastname

DateDate Datwen

lastnamelastname

publisher

(year=“1998”)

root

04/2000 XML-QL 29

Element Identity, IDs, and ID Reference:

XML reserve an attribute of type ID, which allows a unique key to be associated with an element.

An attribute IDREF allows an element to refer to another element with the designated key, and IDREFS may refer to multiple elements.

Example: adding attribute ID and author types ID and IDREFS:

<!ATTLIST person ID ID #REQUIRED>

<!ATTLIST article auther IDREFS #IMPLIED>

04/2000 XML-QL 30

Element Identity, IDs, and ID Reference: (cont)

and definitions:<person ID = “o123”>

<firstname> John </firstname><lastname> Smith </lastname>

</person><person ID = “o234”>

...</person><article author = “o123 o234”>

<title> … </title><year> 1995 </year>

</article>

04/2000 XML-QL 31

XML graph including ID & IDREFS

first name titlefirst namelast name yearlast name

author

personperson

article

John Smith 1995

root

04/2000 XML-QL 32

Writing queries using IDs Without IDs:

WHERE <article><author><lastname> $n </></></> IN “abc.xml”

Using IDREF: (All last name, title pairs) WHERE <article author = $i>

<title> </> ELEMENT_AS $t

</>,

<person ID = $i>

<lastname> </> ELEMENT_AS $l

</>

CONSTRUCT <result> $t $l </>

04/2000 XML-QL 33

Another Example:

<catalogue>

<book id = “b1”

author idref = “a1”>

<title>Memoris…</title>

<year>1997</year>

</book>

</author id = “a1”>

<publication idref = “b1”>

<first>Arthur</first>

<last>Golden</last>

</author>

</catalogue>

catalogue

book author

GoldenArthur1997Memories...

publication

author

oid1

oid2

b1 a1

publication=b1author=a1

04/2000 XML-QL 34

Scalar Values:Only leaf nodes in the XML may contain values, and

they may have only one value. example: the XML fragment:

<title> A trip to <titlepart> The Moon </titlepart> </title>

can be translated in order to fit the data model into:

<title>

<CDATA> A trip to </CDATA>

<titlepart> <CDATA> The Moon </CDATA> </titlepart>

</title>The value of a leaf node is its oid.

04/2000 XML-QL 35

Scalar Values: (cont)

<title>

<CDATA>A trip to </CDATA>

<titlepart> <CDATA> The Moon </CDATA> </titlepart>

</title>

CDATA

CDATA

title

titlepart

“The Moon”

“A trip to”

XML graph ->

04/2000 XML-QL 36

Element Order

XML-QL supports two distinct data model: an unordered and ordered one.

An ordered graph is like an unordered one but include , for each node, a total order on its successors.

The price for an ordered model is a more complex semantic of the query language and less efficient.

04/2000 XML-QL 37

Mapping XML-graphs into XML-documents

XML graph don’t have a unique representation, as XML document because: element order is unspecified. sharing of nodes.

To create a XML document we have to choose some order that conform to a DTD.

04/2000 XML-QL 38

Outline Introduction

Examples in XML-QL

A Data Model for XML

Advanced Examples in XML-QL

Extensions and Open Issues

Summary

04/2000 XML-QL 39

Advanced examples in XML-QLTag VariablesRegular - path ExpressionsTransforming XML data Integrating from multiple XML sourcesNo schema requiredFunctions definitions and DTD’sExternal functionsOrdered model - Sorting, Indexing

04/2000 XML-QL 40

Tag Variables, No schema required

WHERE < $p > -- $p can be {article, book}

<title> $t </>

<year>1995 </> -- referring attr. as an element

< $e ><lastname> Date </> </>

</> IN "bib.xml",

$e IN {author, editor}

CONSTRUCT < $p >

<title> $t </>

< $e > Date </>

</>

All publications published in 1995 in which Date is either an author, or an editor

04/2000 XML-QL 41

Query Result

<book>

<author>Date</author>

<title>An Introduction to Database Systems </title>

</book>

<article>

<author>Date</author>

<title>The New Jersey Machine-Code Toolkit</title>

</article>

04/2000 XML-QL 42

Regular Path Expressions

XML data can specify nested and cyclic structures, such as trees, directed acyclic graphs, and arbitrary graphs.

The following DTD defines a self-recursive element part:<!ELEMENT part (name brand part*)>

<!ELEMENT name CDATA>

<!ELEMENT brand CDATA>

04/2000 XML-QL 43

Regular Path Expressions (cont)

Here part* is a regular path expression, and

matches any sequence of edges, all of which

are labeled part:

WHERE < part* >

<name> $r </>

<brand> Ford </>

</> IN "www.a.b.c/parts.xml"

CONSTRUCT <result> $r </>

04/2000 XML-QL 44

Regular Path Expressions (cont)

the path definition :<part*><name> $r </><brand> Ford </> </>

is equivalent to the following infinite sequence of patterns:

<name> $r </> <brand> Ford </> <part> <name> $r </> <brand> Ford </> </> <part> <part> <name> $r </> <brand> Ford </> </> </> <part> <part> <part> <name> $r </> <brand> Ford </>

</> </> </> ...

04/2000 XML-QL 45

Regular Path Expressions (cont)

The wildcard ‘ * ‘ matches any tag and appear wherever a tag is permitted:

Example:

WHERE < $* >

<name> $r </>

<brand> Ford </>

</> IN "www.a.b.c/parts.xml"

CONSTRUCT <result> $r </>

04/2000 XML-QL 46

Regular Path Expressions (cont)

‘ . ‘ denotes concatation of regular expression

<part.part.name>……</> = <part><part><name>… … </></></>

‘ | ‘ denotes alternation of regular expression

‘ + ‘ operator means one or more:

<part+> = <part.part*>

Tag variables make it possible to write a query that can be applied to two or more XML data sources with similar but not identical DTDs.

04/2000 XML-QL 47

Regular Path Expressions (cont)

WHERE <*.Part+.(subpart|component)> $r </>

IN ”parts.xml” -- please take a look at parts.XML

CONSTRUCT <result>$r</>

Result:<result><name>Motor</name><brand>Hamilton</brand></result>

<result>

<brand>B&O</brand>

<part><name>A2D</name> <brand>AMD</brand></part>

<name>Woofer</name>

</result>

<result><name>Speakers</name><brand>Labtec</brand></result>

04/2000 XML-QL 48

Transforming XML dataTranslate data from one DTD into another.Example: besides the BIB. DTD we have other

DTD that defines a person:

<!ELEMENT person (lastname, firstname,

address?, phone?, publicationtitle*)Next query transform data that conforms to

BIB.DTD into data that conforms to Person DTD.The Query uses OID’s(Object identifiers) and

Skolem functions to group results in the same <person> element.

04/2000 XML-QL 49

Transforming XML data with Skolem function

WHERE <$*> <author> <firstname> $fn </> <lastname> $ln </>

</><title> $t </>

</> IN "www.a.b.c/bib.xml",CONSTRUCT <person ID=PersonID($fn, $ln)> <firstname> $fn </> <lastname> $ln </> <publicationtitle> $t </> </>

04/2000 XML-QL 50

Query Result

<person> <firstname>Mary</firstname><lastname>Fernandez</lastname><publicationtitle>The New Jersey Machine-Code

Toolkit</publicationtitle></person><person>

<firstname>Dan</firstname><lastname>Date</lastname><publicationtitle>The New Jersey Machine-Code

Toolkit</publicationtitle></person>

04/2000 XML-QL 51

Integrating data from multiple XML sources

WHERE <person><name></> ELEMENT_AS $n

<ssn> $ssn </> </> IN ”payroll.xml", -- take a look at payroll.XML <taxpayer> <ssn> $ssn </> <income></> ELEMENT_AS $i </> IN "taxpayers.xml” -- take a look…CONSTRUCT <result> $n $i </>

04/2000 XML-QL 52

Integrating data from multiple XML sources (result)

<result><income>55000</income><name>M.Smith</name>

</result><result>

<income>1430000</income> <name>R. Johnson</name>

</result><result>

<income>35000</income> <name>J. Doe</name>

</result>

04/2000 XML-QL 53

Integrating data from multiple XML sources (Skolem function)

{ WHERE <person> <name> </> ELEMENT_AS $n<ssn> $ssn </>

</> IN ”payroll.xml" CONSTRUCT <result ID=SSNID($ssn)> $n </>}{ WHERE <taxpayer>

<ssn> $ssn </><income> </> ELEMENT_AS $i

</> IN "taxpayers.xml" CONSTRUCT <result ID=SSNID($ssn)> $n $i </>}

04/2000 XML-QL 54

Integrating data (result)

<result>

<name>M. Smith</name>

<income>55000</income>

</result>

<result><income>120000</income></result>

<result>

<name>R. Johnson</name>

<income>1430000</income>

</result>

<result><name>P. Kent</name></result>

<result>

<name>J. Doe</name> <income>35000</income>

</result>

04/2000 XML-QL 55

Integrating data (cont) All titles published in ‘95, in addition the month of journal articles and the publishers for books:WHERE < $e >

<title> $t </><year> 1995 </>

</> CONTENT_AS $p IN "www.a.b.c/bib.xml"CONSTRUCT <result ID=ResultID($p)> <title> $t </> </>

{ WHERE $e = ”article",<month> $m </> IN $p

CONSTRUCT <result ID=ResultID($p)> <month> $m </> </> }{ WHERE $e = "book",

<publisher> $q </> IN $p CONSTRUCT <result ID=ResultID($p)> <publisher> $q </> </> }

04/2000 XML-QL 56

Query Result

<result>

<title>The New Jersey Machine-Code Toolkit</title>

<month>June</month>

</result>

<result>

<title>An Introduction to Database Systems </title>

<publisher>Addison Wesley</publisher>

</result>

04/2000 XML-QL 57

Functions definitions and DTD’s

function query() {

CONSTRUCT <result>findDeclaredIncomes("taxpayers.xml","payroll.xml")

</result>}function findDeclaredIncome($Taxpayers,$Employees) {

WHERE <taxpayer><ssn> $s </> <income> $x </></> IN $Taxpayer,

<employee><ssn> $s </> <name> $n </> </> IN $Employees

CONSTRUCT <result><name> $n </><income> $x </> </>}

04/2000 XML-QL 58

Functions definitions and DTD’s (cont)

Restrictions by DTD’s:function findDeclaredIncome (

$Taxpayers:”www.irs.gov/tp.dtd”,

$Employees:”www.employees.org/employeess.dtd”

:“www.my.site.com/myresult.dtd” )

{

WHERE ….

CONSTRUCT ….

}

04/2000 XML-QL 59

Embedding queries in data<result>

<articles>WHERE <article> <title> $t </><year> $y </>

</> IN “www.a.b.c/bib.xml”, $y > 1995CONSTRUCT <title> $t </>

</><books>

WHERE <book> <title> $t </> <year> $y </> </> IN “www.a.b.c/bib.xml”, $y >1995

CONSTRUCT <title> $t </> </>

</>

04/2000 XML-QL 60

Support for an ordered model:

Variable order is important for binding Example:

WHERE <a><b> $x </b> <c> $y </c> </a> -- and WHERE <a><c> $y </c> <b> $x </b> </a>

will match the same objects but by different order. Lets take the following XML data:

<a><b> string1 </b><c> string2 </c><b> string3 </b><c> string4 </c>

</a>

04/2000 XML-QL 61

Support for ordered model (cont)

Under the definition of where in

WHERE <a><b> $x </b> <c> $y </c> </a>

The output will be in the order : $x $y

string1 string2

string1 string4

string3 string2

string3 string4

04/2000 XML-QL 62

Support for ordered model (cont)

Under the definition of where in

WHERE <a><c> $y </c> <b> $x </b> </a>

The output will be in the order : now the output will be in the ordered first by $y and than by $x)

$x $y

string1 string2

string3 string2

string1 string4

string3 string4

04/2000 XML-QL 63

Indexes for element:

XML support element-order variables.Example:

<a[$i]> … </>

<$x[$j]> … </>here $i and $j are bind to an integer 0,

1, 2 … that represent the index in the local order of the edges.

04/2000 XML-QL 64

Indexes for element (graph)

(year=“1995”)

book [0] book[1]

title[0]author[2]

publisher[1]

title[0] author[3]

author[2]

name[0]An introduction …

Addison-Wesley

Addison-Wesley

Foundations for ...

name[0] lastname[0]

DateDate Datwen

lastname[0]

lastname[0]

publisher[1]

(year=“1998”)

( 1 )

( 13 )

( 12 )

( 11 )

( 10 )( 9 )

( 8 )

( 7 )( 5 )

( 6 )( 4)( 3 )

( 2 )

( 15 )

( 14 )

root

04/2000 XML-QL 65

Indexes for element: (cont.)

Example:

retrieves all the persons whose lastname precedes the firstname:

WHERE <person> $p </> IN “www.a.b.c/people.xml”

<firstname [$k] > $x </> IN $p,

<lastname[$j] > $y </> IN $p,

$j < $k

CONSTRUCT <person> $p </>

04/2000 XML-QL 66

ORDER-BY:Order publications by year and month:preserve the order in the original document for publications within the same year/month

WHERE <pub> $p </> IN “www.a.b.c/people.xml”,<title> $t </> IN $p,<year> $y </> IN $p,<month> $m </> IN $p

ORDER-BY value($y),value($m)

CONSTRUCT <result> $t </> value function returns the CDATA value of a node In the absence of value the result would be ordered by OIDs

04/2000 XML-QL 67

ORDER-BY: (cont.)

Reverse the order of all authors in a publication:

WHERE <pub> $p </> IN “www.a.b.c/people.xml”,CONSTRUCT <pub>

WHERE <author[$k]> $a </> IN $pORDER-BY $k DESCENDINGCONSTRUCT <author> $a </>WHERE < $e > $v </> IN $p

$e != “author”CONSTRUCT <$e> $v </>

</pub>

04/2000 XML-QL 68

Outline Introduction

Examples in XML-QL

A Data Model for XML

Advanced Examples in XML-QL

Extensions and Open Issues

Summary

04/2000 XML-QL 69

Extensions and open issues:

EntitiesUser-defined predicatesString regular expressionsName spacesAggregatesXML syntaxExtensions to other XML-related standard

04/2000 XML-QL 70

EntitiesRecognizing entity references:

e.g : <!ENTITY % M “Mary” >

04/2000 XML-QL 71

WHERE <person>

<firstname> &M </>

<address> $a </>

</> ELEMENT_AS $x IN “abc.xml”,

ATTAddress($a)

CONSTRUCT $x

User-defined predicates

04/2000 XML-QL 72

WHERE <person>

<firstname> &M </>

<lastname> ‘Fern*’ </>

<address> $a </>

</> ELEMENT_AS $x IN “abc.xml”,

ATTAddress($a)

CONSTRUCT $x

String regular expressions

04/2000 XML-QL 73

Name spaces

WHERE <person>

<lastname> ‘Fern*’ </>

<US:address> $a </>

</> ELEMENT_AS $x IN “abc.xml”,

ATTAddress($a)

CONSTRUCT $x

04/2000 XML-QL 74

Aggregated

WHERE <book>

<publisher> </> ELEMENT_AS $p,

<price> $x </>,

</> IN “bib.xml”

GROUP-BY $p

CONSTRUCT <result ID=f($p)> $p

<lowest-price> $min($x) </>

<highest-price> $max($x) </>

</>

04/2000 XML-QL 75

Outline Introduction

Examples in XML-QL

A Data Model for XML

Advanced Examples in XML-QL

Extensions and Open Issues

Summary

04/2000 XML-QL 76

Other Query Languages

XSL vs. XML-QL XSL - Intended primarily for specifying style and

layout of XML documents, consists: Transformation operations Formatting vocabulary

XML-QL XSLXML output x xno schema required x xdata extraction x xdata restructuring x xdata integration xschema browsing x xrelational complete x

04/2000 XML-QL 77

Other Query Languages(cont)

Other competents query languages are: Lorel, YATL, XQL, XML-GL, WEBL

Comparison of simple query:XML-QL

CONSTRUCT <bib> {

WHERE <bib> <book year=$y>

<title>$t</> <publisher><name>Addison-Wesley</></>

</>

</bib> IN “www.bn.com/bib.xml”,

$y>1991

CONSTRUCT <book year=$y><title>$t</></>

} </bib>

04/2000 XML-QL 78

Other Query Languages(cont)

YATL

make

bib [ *book [ @year [ $y ],

title [ $t ] ] ]

match “www.bn.com/bib.xml” with

bib [ *book [ @year [ $y ],

title [ $t ] ],

publisher [ name [ $n ] ] ]

where

$n = “Addison-Wesley” and $y > 1991

04/2000 XML-QL 79

Other Query Languages(cont)

XQL:

document(“http://www.bn.com”)/bib {

book[publisher/name=“Addison-Wesley” and @year>1991] { @year | title }

} -- XQL doesn’t have constructor clause

04/2000 XML-QL 80

Other Query Languages(cont)

LOREL:

select xml(bib:(

(select xml(book:{@year:y, title:t})

from bib.book b, b.title t, b.year y

where b.publisher = “Addison-Wesley” and y>1991)})

04/2000 XML-QL 81

Other Query Languages(cont)

XML-QL LOREL XSL XQL XML-GL

XML output x x x x

All Query operations x x x

No schema required x x x x x

XML representation x

XML embedded x x x x

Exploit avail. schema x x

Preserve order x x x x x

04/2000 XML-QL 82

Summary/Conclusions XML-QL is a declarative language which provides

support for querying, constructing, transforming, and integrating XML data

XML-QL supports both ordered and unordered view on XML document

XML-QL is based on similar database research suggested model of Semi-structured data

XML-QL satisfy the absolute set of requirements from query language cited in XML Query Requirements of W3C Working Draft

XML-QL is good candidate to be the new XML standard query language

04/2000 XML-QL 83

BibliographyArticles: XML-QL:A Query Language for XML, W3C 19/8/98, 99

Quering XML Data - IEEE1999

XML Query Requirements - W3c Working draft 31/1/00

XML Query Languages:Experiences and Exemplars-~mff

WWW sites: www.research.att.com/~mff/xmlql

db.cis.upenn.edu/~adeutsch/xmlql-demo/html/

www-db.research.belllabs.com/user/simeon/ xquery.html

04/2000 XML-QL 84

Appendix - XML data Examples:

BIB . DTD:

<!ELEMENT book (author+, title, publisher)>

<!ATTLIST book year CDATA>

<!ELEMENT article (author+, title, year?, (shortversion|longversion))>

<!ATTLIST article type CDATA>

<!ELEMENT publisher (name, address)>

<!ELEMENT author (firstname?, lastname)>

04/2000 XML-QL 85

Appendix - XML data Examples:

BIB . XML:<bib> <book year="1995">

<!-- A good introductory text --><title> An Introduction to Database Systems </title><author> <lastname> Date </lastname> </author><publisher><name> Addison-Wesley </name ></publisher>

</book> <book year="1998">

<title> Foundation for Object/Relational Databases: The ThirdManifesto </title>

<author> <lastname> Date </lastname> </author><author> <lastname> Darwen </lastname> </author><publisher> <name> Addison-Wesley </name > </publisher>

</book></bib>

04/2000 XML-QL 86

Appendix - XML data Examples

Parts.DTD:

<?xml version="1.0"?><!DOCTYPE Parts [<!ELEMENT Parts (part+)><!ELEMENT part (name,brand,(part|subpart|component)*)><!ELEMENT subpart (name, brand) ><!ELEMENT component (name, brand, part*) ><!ELEMENT name (#PCDATA)><!ELEMENT brand (#PCDATA)>]>

04/2000 XML-QL 87

Appendix - XML data Examples

Parts.XML:

<Parts><part>

<name>Green Power Juicer</name><brand>Green Power</brand><subpart>

<name>Motor</name><brand>Hamilton</brand>

</subpart></part>

04/2000 XML-QL 88

Appendix - XML data ExamplesParts.XML continue...

<part> <name>Toyota Tercel</name> <brand>Toyota</brand> <part> <name>Sony Stereo X11-3</name> <brand>Sony</brand> <component> <name>Woofer</name>

<brand>B&amp;O</brand> <part><name>A2D</name>

<brand>AMD</brand></part></component><subpart>

<name>Speakers</name><brand>Labtec</brand>

</subpart></part>

</part></Parts>

04/2000 XML-QL 89

Appendix - XML data ExamplesPayroll.XML<Payroll>

<person><ssn>100-0000-001</ssn><name>J. Doe</name><salary>35000</salary> </person>

<person><ssn>100-0000-002</ssn><name>M. Smith</name><salary>73000</salary> </person>

<person><ssn>100-0000-003</ssn><name>R. Johnson</name><salary>1400000</salary> </person>

<person><ssn>100-0000-004</ssn><name>P. Kent</name><salary>33000</salary> </person>

</Payroll>

04/2000 XML-QL 90

Appendix - XML data ExamplesTaxPayers.XML:<IRS>

<taxpayer> <ssn>100-0000-001</ssn><income>35000</income><taxes>7000</taxes> </taxpayer>

<taxpayer> <ssn>100-0000-002</ssn><income>55000</income><taxes>3000</taxes> </taxpayer>

<taxpayer><ssn>100-0000-003</ssn><income>1430000</income><taxes>25000</taxes> </taxpayer>

<taxpayer> <ssn>100-0000-005</ssn><income>120000</income><taxes>30000</taxes> </taxpayer>

</IRS>

Recommended