SlideShare uma empresa Scribd logo
1 de 13
Baixar para ler offline
7/9/2019
Prepared By: Dr.Saranya.K.G 1
XQUERY
Prepared By:Dr.Saranya K.G
What is Xquery?
• XQuey is a standardized language that can be used to query XML
documents.
• XQuery queries of XML data are built using XPath expressions.
Prepared By:Dr.Saranya K.G
7/9/2019
Prepared By: Dr.Saranya.K.G 2
<?xml version="1.0" encoding="ISO-8859-1"?>
<bookstore>
<book category="COOKING">
<title lang="en"> Everyday Italian </title>
<author> Giada De Laurenties </author>
<year>2005</year>
<price>30.00</price>
</book>
<book category="CHILDREN">
<title lang="en"> Harry Potter </title>
<author> J.K. Rowling </author>
<year> 2005</year>
<price> 29.99 </price>
</book>
<book category="WEB">
<title lang="en"> XQUERY KICK START </title>
<author> JAMES MCGOVEN </author>
<author> PER BOTHNER </author>
<author> KURT CAGLE </author>
<author> JAMES LINE </author>
<author> GIRIJA VAIDYANATHAN </author>
<year> 2003 </year>
<price> 49.99 </price>
</book>
<book category="WEB">
<title lang="en"> LEARNING XML </title>
<author> ERICK T ROY </author>
<year> 2003 </year>
<price> 39.95 </price>
</book>
</bookstore>
Prepared By:Dr.Saranya K.G
doc() function
doc("books.xml")
The doc() function is used to open an XML document.
doc("books.xml")/bookstore/book/title
<title lang="en"> EVERYDAY ITALIAN </title>
<title lang="en"> HARRY POTTER </title>
<title lang="en"> XQUERY KICK START </title>
<title lang="en"> LEARNING XML </title>
Prepared By:Dr.Saranya K.G
7/9/2019
Prepared By: Dr.Saranya.K.G 3
Xpath Expressions
Prepared By:Dr.Saranya K.G
<?xml version="1.0" encoding="ISO-8859-1"?>
<bookstore>
<book category="COOKING">
<title lang="en"> Everyday Italian </title>
<author> Giada De Laurenties </author>
<year>2005</year>
<price>30.00</price>
</book>
<book category="CHILDREN">
<title lang="en"> Harry Potter </title>
<author> J.K. Rowling </author>
<year> 2005</year>
<price> 29.99 </price>
</book>
<book category="WEB">
<title lang="en"> XQUERY KICK START </title>
<author> JAMES MCGOVEN </author>
<author> PER BOTHNER </author>
<author> KURT CAGLE </author>
<author> JAMES LINE </author>
<author> GIRIJA VAIDYANATHAN </author>
<year> 2003 </year>
<price> 49.99 </price>
</book>
<book category="WEB">
<title lang="en"> LEARNING XML </title>
<author> ERICK T ROY </author>
<year> 2003 </year>
<price> 39.95 </price>
</book>
</bookstore>
/bookstore/book[price<30]
<book category="CHILDREN">
<title lang = "en"> Harry Potter </title>
<author> J.K.Rowling </author>
<year> 2005 </year>
<price> 29.99 </price>
</book>
Prepared By:Dr.Saranya K.G
7/9/2019
Prepared By: Dr.Saranya.K.G 4
FLWOR
FLWOR stands for:
• FOR - selects a sequence of nodes
• LET - binds a sequence to a variable
• WHERE - filters the nodes
• ORDER BY - sorts the nodes
• RETURN - what to return (gets evaluated once
for every node)
Prepared By:Dr.Saranya K.G
FLWOR example
/bookstore/book[price>30]/title
for $x in /bookstore/book
where $x/price>30
return $x/title
<title lang="en"> XQuery Kick Start
</title>
<title lang="en"> Learning XML </title>
<?xml version="1.0" encoding="ISO-8859-1"?>
<bookstore>
<book category="COOKING">
<title lang="en"> Everyday Italian </title>
<author> Giada De Laurenties </author>
<year>2005</year>
<price>30.00</price>
</book>
<book category="CHILDREN">
<title lang="en"> Harry Potter </title>
<author> J.K. Rowling </author>
<year> 2005</year>
<price> 29.99 </price>
</book>
<book category="WEB">
<title lang="en"> XQUERY KICK START </title>
<author> JAMES MCGOVEN </author>
<author> PER BOTHNER </author>
<author> KURT CAGLE </author>
<author> JAMES LINE </author>
<author> GIRIJA VAIDYANATHAN </author>
<year> 2003 </year>
<price> 49.99 </price>
</book>
<book category="WEB">
<title lang="en"> LEARNING XML </title>
<author> ERICK T ROY </author>
<year> 2003 </year>
<price> 39.95 </price>
</book>
</bookstore>
Prepared By:Dr.Saranya K.G
7/9/2019
Prepared By: Dr.Saranya.K.G 5
ORDER BY
for $x in /bookstore/book
where $x/price>30
Order by $x/title
return $x/title
<title lang="en"> Learning XML </title>
<title lang="en"> XQuery Kick Start </title>
<?xml version="1.0" encoding="ISO-8859-1"?>
<bookstore>
<book category="COOKING">
<title lang="en"> Everyday Italian </title>
<author> Giada De Laurenties </author>
<year>2005</year>
<price>30.00</price>
</book>
<book category="CHILDREN">
<title lang="en"> Harry Potter </title>
<author> J.K. Rowling </author>
<year> 2005</year>
<price> 29.99 </price>
</book>
<book category="WEB">
<title lang="en"> XQUERY KICK START </title>
<author> JAMES MCGOVEN </author>
<author> PER BOTHNER </author>
<author> KURT CAGLE </author>
<author> JAMES LINE </author>
<author> GIRIJA VAIDYANATHAN </author>
<year> 2003 </year>
<price> 49.99 </price>
</book>
<book category="WEB">
<title lang="en"> LEARNING XML </title>
<author> ERICK T ROY </author>
<year> 2003 </year>
<price> 39.95 </price>
</book>
</bookstore>
Prepared By:Dr.Saranya K.G
XML output
<u1>
{
for $x in /bookstore/book/title
order by $x
return <li>{$x}</li>
}
</u1>
<u1>
<li> <title lang="en"> Everyday Italian</title></li>
<li><title lang="en">Harry Potter</title></li>
<li><title lang="en">Learning XML Start</title></li>
<li><title lang="en">XQuery Kick Start</title></li>
</u1>
<?xml version="1.0" encoding="ISO-8859-1"?>
<bookstore>
<book category="COOKING">
<title lang="en"> Everyday Italian </title>
<author> Giada De Laurenties </author>
<year>2005</year>
<price>30.00</price>
</book>
<book category="CHILDREN">
<title lang="en"> Harry Potter </title>
<author> J.K. Rowling </author>
<year> 2005</year>
<price> 29.99 </price>
</book>
<book category="WEB">
<title lang="en"> XQUERY KICK START </title>
<author> JAMES MCGOVEN </author>
<author> PER BOTHNER </author>
<author> KURT CAGLE </author>
<author> JAMES LINE </author>
<author> GIRIJA VAIDYANATHAN </author>
<year> 2003 </year>
<price> 49.99 </price>
</book>
<book category="WEB">
<title lang="en"> LEARNING XML </title>
<author> ERICK T ROY </author>
<year> 2003 </year>
<price> 39.95 </price>
</book>
</bookstore>
Prepared By:Dr.Saranya K.G
7/9/2019
Prepared By: Dr.Saranya.K.G 6
data() function
<u1>
[
for $x in /bookstore/book/title
order by $x
return <li>{data($x)}</li>
}
</u1>
<u1>
<li>Everyday Italian</li>
<li>Harry Potter</li>
<li>Learning XML</li>
<li>XQuery Kick Start</li>
</u1>
<?xml version="1.0" encoding="ISO-8859-1"?>
<bookstore>
<book category="COOKING">
<title lang="en"> Everyday Italian </title>
<author> Giada De Laurenties </author>
<year>2005</year>
<price>30.00</price>
</book>
<book category="CHILDREN">
<title lang="en"> Harry Potter </title>
<author> J.K. Rowling </author>
<year> 2005</year>
<price> 29.99 </price>
</book>
<book category="WEB">
<title lang="en"> XQUERY KICK START </title>
<author> JAMES MCGOVEN </author>
<author> PER BOTHNER </author>
<author> KURT CAGLE </author>
<author> JAMES LINE </author>
<author> GIRIJA VAIDYANATHAN </author>
<year> 2003 </year>
<price> 49.99 </price>
</book>
<book category="WEB">
<title lang="en"> LEARNING XML </title>
<author> ERICK T ROY </author>
<year> 2003 </year>
<price> 39.95 </price>
</book>
</bookstore>
Prepared By:Dr.Saranya K.G
if-then-else
for $x in /bookstore/book
return if ($x/@category="CHILDREN")
then <child>{data ($x/title)}</child>
else <adult>{data($x/title)}</adult>
<adult>Everyday Italian</adult>
<child>Harry Potter</child>
<adult>Learning XML</adult>
<adult>XQuery Kick Start</adult>
<?xml version="1.0" encoding="ISO-8859-1"?>
<bookstore>
<book category="COOKING">
<title lang="en"> Everyday Italian </title>
<author> Giada De Laurenties </author>
<year>2005</year>
<price>30.00</price>
</book>
<book category="CHILDREN">
<title lang="en"> Harry Potter </title>
<author> J.K. Rowling </author>
<year> 2005</year>
<price> 29.99 </price>
</book>
<book category="WEB">
<title lang="en"> XQUERY KICK START </title>
<author> JAMES MCGOVEN </author>
<author> PER BOTHNER </author>
<author> KURT CAGLE </author>
<author> JAMES LINE </author>
<author> GIRIJA VAIDYANATHAN </author>
<year> 2003 </year>
<price> 49.99 </price>
</book>
<book category="WEB">
<title lang="en"> LEARNING XML </title>
<author> ERICK T ROY </author>
<year> 2003 </year>
<price> 39.95 </price>
</book>
</bookstore>
Prepared By:Dr.Saranya K.G
7/9/2019
Prepared By: Dr.Saranya.K.G 7
FOR and LET
FOR
generates a list of bindings of the
variable to each element.
for $x in (1 to 5)
return <test>{$x}</test>
<test>1</test>
<test>2</test>
<test>3</test>
<test>4</test>
<test>5</test>
LET
generates a single binding of the variable
to the list of elements.
let $x := (1 to 5)
return <test>{$x}</test>
<test> 1 2 2 4 5 </test>
Prepared By:Dr.Saranya K.G
at
for $x at $i
in /bookstore/book/title
return <book>{$i}.{data($x)}</book>
The at keyword can be used to count the iteration.
<book>1. Everyday Italian </book>
<book>2. Harry Potter </book>
<book>3. XQuery Kick Start </book>
<book>4. Learning XML </book>
<?xml version="1.0" encoding="ISO-8859-1"?>
<bookstore>
<book category="COOKING">
<title lang="en"> Everyday Italian </title>
<author> Giada De Laurenties </author>
<year>2005</year>
<price>30.00</price>
</book>
<book category="CHILDREN">
<title lang="en"> Harry Potter </title>
<author> J.K. Rowling </author>
<year> 2005</year>
<price> 29.99 </price>
</book>
<book category="WEB">
<title lang="en"> XQUERY KICK START </title>
<author> JAMES MCGOVEN </author>
<author> PER BOTHNER </author>
<author> KURT CAGLE </author>
<author> JAMES LINE </author>
<author> GIRIJA VAIDYANATHAN </author>
<year> 2003 </year>
<price> 49.99 </price>
</book>
<book category="WEB">
<title lang="en"> LEARNING XML </title>
<author> ERICK T ROY </author>
<year> 2003 </year>
<price> 39.95 </price>
</book>
</bookstore>
Prepared By:Dr.Saranya K.G
7/9/2019
Prepared By: Dr.Saranya.K.G 8
for $x in (10,20), $y in (100,200)
return <test>x={$x} and y={$y}</test>
<test>x=10 and y=100</test>
<test>x=10 and y=200</test>
<test>x=20 and y=100</test>
<test>x=20 and y=200</test>
for $x at $i in (10,20), $y at $j in (100,200)
return <test>{$i}. x={$x} and {$j}. y={$y}</test>
<test>1. x=10 and 1. y=100 </test>
<test>1. x=10 and 2. y=200 </test>
<test>2. x=20 and 1.y=100</test>
<test>2. x=20 and 2. y=200</test>
Prepared By:Dr.Saranya K.G
some, every,in,satisfies
for $b in //book
where some $p in $b/author satisfies
(contains ($p,"in"))
return $b/title
<title lang="en"> Harry Potter</title>
<title lang="en">XQuery Kick Start</title>
for $b in //book
where every $p in $b/author satisfies
(contains($p,"in"))
return $b/title
<title lang="en">Harry Potter</title>
<?xml version="1.0" encoding="ISO-8859-1"?>
<bookstore>
<book category="COOKING">
<title lang="en"> Everyday Italian </title>
<author> Giada De Laurenties </author>
<year>2005</year>
<price>30.00</price>
</book>
<book category="CHILDREN">
<title lang="en"> Harry Potter </title>
<author> J.K. Rowling </author>
<year> 2005</year>
<price> 29.99 </price>
</book>
<book category="WEB">
<title lang="en"> XQUERY KICK START </title>
<author> JAMES MCGOVEN </author>
<author> PER BOTHNER </author>
<author> KURT CAGLE </author>
<author> JAMES LINN </author>
<author> GIRIJA VAIDYANATHAN </author>
<year> 2003 </year>
<price> 49.99 </price>
</book>
<book category="WEB">
<title lang="en"> LEARNING XML </title>
<author> ERICK T ROY </author>
<year> 2003 </year>
<price> 39.95 </price>
</book>
</bookstore>
Prepared By:Dr.Saranya K.G
7/9/2019
Prepared By: Dr.Saranya.K.G 9
sum
let $p := for $b in //book return number($b/price)
return <s>{$p}</s>
<s>30 29.99 49.99 39.95 </s>
let $p := for $b in //book return number ($b/price)
return <s> {sum($p)}</s>
<s> 149.93 </s>
<?xml version="1.0" encoding="ISO-8859-1"?>
<bookstore>
<book category="COOKING">
<title lang="en"> Everyday Italian </title>
<author> Giada De Laurenties </author>
<year>2005</year>
<price>30.00</price>
</book>
<book category="CHILDREN">
<title lang="en"> Harry Potter </title>
<author> J.K. Rowling </author>
<year> 2005</year>
<price> 29.99 </price>
</book>
<book category="WEB">
<title lang="en"> XQUERY KICK START </title>
<author> JAMES MCGOVEN </author>
<author> PER BOTHNER </author>
<author> KURT CAGLE </author>
<author> JAMES LINE </author>
<author> GIRIJA VAIDYANATHAN </author>
<year> 2003 </year>
<price> 49.99 </price>
</book>
<book category="WEB">
<title lang="en"> LEARNING XML </title>
<author> ERICK T ROY </author>
<year> 2003 </year>
<price> 39.95 </price>
</book>
</bookstore>
Prepared By:Dr.Saranya K.G
Sequence
let $p := //book/price
let $y := //book/year
return ($p,$y)
<price>30.00</price>
<price>29.99</price>
<price>49.99</price>
<price>39.95</price>
<year>2005</year>
<year>2005</year>
<year>2003</year>
<year>2003</year>
<?xml version="1.0" encoding="ISO-8859-1"?>
<bookstore>
<book category="COOKING">
<title lang="en"> Everyday Italian </title>
<author> Giada De Laurenties </author>
<year>2005</year>
<price>30.00</price>
</book>
<book category="CHILDREN">
<title lang="en"> Harry Potter </title>
<author> J.K. Rowling </author>
<year> 2005</year>
<price> 29.99 </price>
</book>
<book category="WEB">
<title lang="en"> XQUERY KICK START </title>
<author> JAMES MCGOVEN </author>
<author> PER BOTHNER </author>
<author> KURT CAGLE </author>
<author> JAMES LINE </author>
<author> GIRIJA VAIDYANATHAN </author>
<year> 2003 </year>
<price> 49.99 </price>
</book>
<book category="WEB">
<title lang="en"> LEARNING XML </title>
<author> ERICK T ROY </author>
<year> 2003 </year>
<price> 39.95 </price>
</book>
</bookstore>Prepared By:Dr.Saranya K.G
7/9/2019
Prepared By: Dr.Saranya.K.G 10
union
//book/(price union year)
//book/(price | title)
<year>2005</year>
<price>30.00</price>
<year>2005</yera>
<price>29.99</price>
<year>2003</year>
<price>49.99</price>
<year>2003</year>
<?xml version="1.0" encoding="ISO-8859-1"?>
<bookstore>
<book category="COOKING">
<title lang="en"> Everyday Italian </title>
<author> Giada De Laurenties </author>
<year>2005</year>
<price>30.00</price>
</book>
<book category="CHILDREN">
<title lang="en"> Harry Potter </title>
<author> J.K. Rowling </author>
<year> 2005</year>
<price> 29.99 </price>
</book>
<book category="WEB">
<title lang="en"> XQUERY KICK START </title>
<author> JAMES MCGOVEN </author>
<author> PER BOTHNER </author>
<author> KURT CAGLE </author>
<author> JAMES LINE </author>
<author> GIRIJA VAIDYANATHAN </author>
<year> 2003 </year>
<price> 49.99 </price>
</book>
<book category="WEB">
<title lang="en"> LEARNING XML </title>
<author> ERICK T ROY </author>
<year> 2003 </year>
<price> 39.95 </price>
</book>
</bookstore>
Prepared By:Dr.Saranya K.G
intersect
let $b := //book
return $b[year="2005"] intersect
$b[number(price)>=30]
<book category="COOKING">
<title lang="en"> Everyday Italian </title>
<author> Giada De Laurentiis</author>
<yer>2005</year>
<price>30.00</price>
</book>
<?xml version="1.0" encoding="ISO-8859-1"?>
<bookstore>
<book category="COOKING">
<title lang="en"> Everyday Italian </title>
<author> Giada De Laurenties </author>
<year>2005</year>
<price>30.00</price>
</book>
<book category="CHILDREN">
<title lang="en"> Harry Potter </title>
<author> J.K. Rowling </author>
<year> 2005</year>
<price> 29.99 </price>
</book>
<book category="WEB">
<title lang="en"> XQUERY KICK START </title>
<author> JAMES MCGOVEN </author>
<author> PER BOTHNER </author>
<author> KURT CAGLE </author>
<author> JAMES LINE </author>
<author> GIRIJA VAIDYANATHAN </author>
<year> 2003 </year>
<price> 49.99 </price>
</book>
<book category="WEB">
<title lang="en"> LEARNING XML </title>
<author> ERICK T ROY </author>
<year> 2003 </year>
<price> 39.95 </price>
</book>
</bookstore>
Prepared By:Dr.Saranya K.G
7/9/2019
Prepared By: Dr.Saranya.K.G 11
except
//book/(* except author)
<title lang="en">Everyday Italian</title>
<year>2005</year>
<price>30.00</price>
<title lang="en">Harry Potter</title>
<year>2005</year>
<price>29.99</price>
<title lang="en">XQuery Kick
Start</title>
<year>2003</year>
<price>49.99</price>
<title lang="en"> Learning XML </title>
<year>2003</year>
<price>39.95</price>
<?xml version="1.0" encoding="ISO-8859-1"?>
<bookstore>
<book category="COOKING">
<title lang="en"> Everyday Italian </title>
<author> Giada De Laurenties </author>
<year>2005</year>
<price>30.00</price>
</book>
<book category="CHILDREN">
<title lang="en"> Harry Potter </title>
<author> J.K. Rowling </author>
<year> 2005</year>
<price> 29.99 </price>
</book>
<book category="WEB">
<title lang="en"> XQUERY KICK START </title>
<author> JAMES MCGOVEN </author>
<author> PER BOTHNER </author>
<author> KURT CAGLE </author>
<author> JAMES LINE </author>
<author> GIRIJA VAIDYANATHAN </author>
<year> 2003 </year>
<price> 49.99 </price>
</book>
<book category="WEB">
<title lang="en"> LEARNING XML </title>
<author> ERICK T ROY </author>
<year> 2003 </year>
<price> 39.95 </price>
</book>
</bookstore>
Prepared By:Dr.Saranya K.G
number(arg) Returns the numeric value of the argument
abs(num) Returns the absolute value of the argument
ceiling(num) Returns the smallest integer that is greater than the
number argument
floor(num) Returns the largest integer that is not greater than the
number argument
round(num) Rounds the number argument to the nearest integer.
Functions on Numeric Values
Prepared By:Dr.Saranya K.G
7/9/2019
Prepared By: Dr.Saranya.K.G 12
string(arg) Returns the string value of the argument
compare(comp1,comp2) Returns -1 if comp1 is less than comp2,
0 if comp1 is equal to comp2,
or 1 if comp1 is greater than comp2
concat(string,string,..) Returns the concatenation of the strings.
string-join((string,string,…),sep) Retruns a string created by concatenating the string arguments and
using the sep argument as the separator
substring(string,start,len)
substring(string,start)
Returns the substring from the start position to the specified length.
Index of the first character is 1. If length is omitted it returns the
substring from the start position to the end.
string-length(string)
string-length()
Returns the length of the specified string. If there is no string
argument it returns the length of the string value of the current node.
normalize-space(string)
normalize-space()
Removes leading and trailing spaces from the specified string and
replaces all internal sequences of white space with one and returns
the result. If there is no string argument it does the same on the
current node.
Functions on Strings1
Prepared By:Dr.Saranya K.G
upper-case(string) Converts the string argument to upper-case
lower-case(string) Converts the string argument to lower-case
contains(string1,string2) Returns true if string1 contains string2.
Otherwise it returns false.
starts-with (string1,string2) Returns true if string1 starts with string2
Otherwise it returns false.
ends-with(string1,string2) Returns true if string1 ends with string2
Otherwise it returns false.
substring-before(string1,string2) Returns the start of string 1 before string2 occurs in it
substring-after(string1,string2) Returns the remainder of string1 after string2 occurs in
it.
matches(string,pattern) Returns true if the string argument matches the pattern.
Otherwise, it returns false.
replace(string,pattern,replace) Returns a string that is created by replacing the given
pattern with the replace argument.
FUNCTIONS ON STRINGS2
Prepared By:Dr.Saranya K.G
7/9/2019
Prepared By: Dr.Saranya.K.G 13
count((item,item,…)) Returns the count of the nodes
avg((arg,arg,..)) Returns the average of the argument values
max((arg,arg,…)) Returns the argument that is greater than the others
min((arg,arg,….)) Returns the argument that is less than the others
sum(arg,arg,…) Returns the sum of the numeric value of each node in
the specified node-set.
Aggregate Functions
Prepared By:Dr.Saranya K.G

Mais conteúdo relacionado

Semelhante a XQuery Fundamentals Explained: A Guide to XML Query Language

Semelhante a XQuery Fundamentals Explained: A Guide to XML Query Language (13)

Xml p2 Lecture Notes
Xml p2 Lecture NotesXml p2 Lecture Notes
Xml p2 Lecture Notes
 
X Query for beginner
X Query for beginnerX Query for beginner
X Query for beginner
 
Expressive objects
Expressive objectsExpressive objects
Expressive objects
 
Xquery basics tutorial
Xquery basics  tutorialXquery basics  tutorial
Xquery basics tutorial
 
Introduction to Schematron
Introduction to SchematronIntroduction to Schematron
Introduction to Schematron
 
Web page concept Basic
Web page concept  BasicWeb page concept  Basic
Web page concept Basic
 
Web page concept final ppt
Web page concept  final pptWeb page concept  final ppt
Web page concept final ppt
 
Xpath & xquery
Xpath & xqueryXpath & xquery
Xpath & xquery
 
Querring xml with xpath
Querring xml with xpath Querring xml with xpath
Querring xml with xpath
 
Xml nisha dwivedi
Xml nisha dwivediXml nisha dwivedi
Xml nisha dwivedi
 
Xml 215-presentation
Xml 215-presentationXml 215-presentation
Xml 215-presentation
 
XML-INTRODUCTION.pdf
XML-INTRODUCTION.pdfXML-INTRODUCTION.pdf
XML-INTRODUCTION.pdf
 
Transforming xml with XSLT
Transforming  xml with XSLTTransforming  xml with XSLT
Transforming xml with XSLT
 

Mais de Dr.Saranya K.G

Mais de Dr.Saranya K.G (12)

complete web service1.ppt
complete web service1.pptcomplete web service1.ppt
complete web service1.ppt
 
Introduction to Web Services Protocols.ppt
Introduction to Web Services Protocols.pptIntroduction to Web Services Protocols.ppt
Introduction to Web Services Protocols.ppt
 
1.Usability Engineering.pptx
1.Usability Engineering.pptx1.Usability Engineering.pptx
1.Usability Engineering.pptx
 
CSSE375-03-framework.ppt
CSSE375-03-framework.pptCSSE375-03-framework.ppt
CSSE375-03-framework.ppt
 
SQA.ppt
SQA.pptSQA.ppt
SQA.ppt
 
Neo4 j
Neo4 jNeo4 j
Neo4 j
 
Xsl xslt
Xsl  xsltXsl  xslt
Xsl xslt
 
Xpath1
Xpath1Xpath1
Xpath1
 
Converting dt ds to xml schemas
Converting dt ds to xml schemasConverting dt ds to xml schemas
Converting dt ds to xml schemas
 
Dtd
DtdDtd
Dtd
 
Xml schema
Xml schemaXml schema
Xml schema
 
1 xml fundamentals
1 xml fundamentals1 xml fundamentals
1 xml fundamentals
 

Último

Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations120cr0395
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...ranjana rawat
 
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlysanyuktamishra911
 
MANUFACTURING PROCESS-II UNIT-1 THEORY OF METAL CUTTING
MANUFACTURING PROCESS-II UNIT-1 THEORY OF METAL CUTTINGMANUFACTURING PROCESS-II UNIT-1 THEORY OF METAL CUTTING
MANUFACTURING PROCESS-II UNIT-1 THEORY OF METAL CUTTINGSIVASHANKAR N
 
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Christo Ananth
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escortsranjana rawat
 
result management system report for college project
result management system report for college projectresult management system report for college project
result management system report for college projectTonystark477637
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Dr.Costas Sachpazis
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...ranjana rawat
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Bookingdharasingh5698
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)simmis5
 
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfKamal Acharya
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...Call Girls in Nagpur High Profile
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingrakeshbaidya232001
 

Último (20)

(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
 
Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024
 
Roadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and RoutesRoadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and Routes
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
 
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghly
 
MANUFACTURING PROCESS-II UNIT-1 THEORY OF METAL CUTTING
MANUFACTURING PROCESS-II UNIT-1 THEORY OF METAL CUTTINGMANUFACTURING PROCESS-II UNIT-1 THEORY OF METAL CUTTING
MANUFACTURING PROCESS-II UNIT-1 THEORY OF METAL CUTTING
 
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
 
result management system report for college project
result management system report for college projectresult management system report for college project
result management system report for college project
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
 
Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)
 
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writing
 

XQuery Fundamentals Explained: A Guide to XML Query Language

  • 1. 7/9/2019 Prepared By: Dr.Saranya.K.G 1 XQUERY Prepared By:Dr.Saranya K.G What is Xquery? • XQuey is a standardized language that can be used to query XML documents. • XQuery queries of XML data are built using XPath expressions. Prepared By:Dr.Saranya K.G
  • 2. 7/9/2019 Prepared By: Dr.Saranya.K.G 2 <?xml version="1.0" encoding="ISO-8859-1"?> <bookstore> <book category="COOKING"> <title lang="en"> Everyday Italian </title> <author> Giada De Laurenties </author> <year>2005</year> <price>30.00</price> </book> <book category="CHILDREN"> <title lang="en"> Harry Potter </title> <author> J.K. Rowling </author> <year> 2005</year> <price> 29.99 </price> </book> <book category="WEB"> <title lang="en"> XQUERY KICK START </title> <author> JAMES MCGOVEN </author> <author> PER BOTHNER </author> <author> KURT CAGLE </author> <author> JAMES LINE </author> <author> GIRIJA VAIDYANATHAN </author> <year> 2003 </year> <price> 49.99 </price> </book> <book category="WEB"> <title lang="en"> LEARNING XML </title> <author> ERICK T ROY </author> <year> 2003 </year> <price> 39.95 </price> </book> </bookstore> Prepared By:Dr.Saranya K.G doc() function doc("books.xml") The doc() function is used to open an XML document. doc("books.xml")/bookstore/book/title <title lang="en"> EVERYDAY ITALIAN </title> <title lang="en"> HARRY POTTER </title> <title lang="en"> XQUERY KICK START </title> <title lang="en"> LEARNING XML </title> Prepared By:Dr.Saranya K.G
  • 3. 7/9/2019 Prepared By: Dr.Saranya.K.G 3 Xpath Expressions Prepared By:Dr.Saranya K.G <?xml version="1.0" encoding="ISO-8859-1"?> <bookstore> <book category="COOKING"> <title lang="en"> Everyday Italian </title> <author> Giada De Laurenties </author> <year>2005</year> <price>30.00</price> </book> <book category="CHILDREN"> <title lang="en"> Harry Potter </title> <author> J.K. Rowling </author> <year> 2005</year> <price> 29.99 </price> </book> <book category="WEB"> <title lang="en"> XQUERY KICK START </title> <author> JAMES MCGOVEN </author> <author> PER BOTHNER </author> <author> KURT CAGLE </author> <author> JAMES LINE </author> <author> GIRIJA VAIDYANATHAN </author> <year> 2003 </year> <price> 49.99 </price> </book> <book category="WEB"> <title lang="en"> LEARNING XML </title> <author> ERICK T ROY </author> <year> 2003 </year> <price> 39.95 </price> </book> </bookstore> /bookstore/book[price<30] <book category="CHILDREN"> <title lang = "en"> Harry Potter </title> <author> J.K.Rowling </author> <year> 2005 </year> <price> 29.99 </price> </book> Prepared By:Dr.Saranya K.G
  • 4. 7/9/2019 Prepared By: Dr.Saranya.K.G 4 FLWOR FLWOR stands for: • FOR - selects a sequence of nodes • LET - binds a sequence to a variable • WHERE - filters the nodes • ORDER BY - sorts the nodes • RETURN - what to return (gets evaluated once for every node) Prepared By:Dr.Saranya K.G FLWOR example /bookstore/book[price>30]/title for $x in /bookstore/book where $x/price>30 return $x/title <title lang="en"> XQuery Kick Start </title> <title lang="en"> Learning XML </title> <?xml version="1.0" encoding="ISO-8859-1"?> <bookstore> <book category="COOKING"> <title lang="en"> Everyday Italian </title> <author> Giada De Laurenties </author> <year>2005</year> <price>30.00</price> </book> <book category="CHILDREN"> <title lang="en"> Harry Potter </title> <author> J.K. Rowling </author> <year> 2005</year> <price> 29.99 </price> </book> <book category="WEB"> <title lang="en"> XQUERY KICK START </title> <author> JAMES MCGOVEN </author> <author> PER BOTHNER </author> <author> KURT CAGLE </author> <author> JAMES LINE </author> <author> GIRIJA VAIDYANATHAN </author> <year> 2003 </year> <price> 49.99 </price> </book> <book category="WEB"> <title lang="en"> LEARNING XML </title> <author> ERICK T ROY </author> <year> 2003 </year> <price> 39.95 </price> </book> </bookstore> Prepared By:Dr.Saranya K.G
  • 5. 7/9/2019 Prepared By: Dr.Saranya.K.G 5 ORDER BY for $x in /bookstore/book where $x/price>30 Order by $x/title return $x/title <title lang="en"> Learning XML </title> <title lang="en"> XQuery Kick Start </title> <?xml version="1.0" encoding="ISO-8859-1"?> <bookstore> <book category="COOKING"> <title lang="en"> Everyday Italian </title> <author> Giada De Laurenties </author> <year>2005</year> <price>30.00</price> </book> <book category="CHILDREN"> <title lang="en"> Harry Potter </title> <author> J.K. Rowling </author> <year> 2005</year> <price> 29.99 </price> </book> <book category="WEB"> <title lang="en"> XQUERY KICK START </title> <author> JAMES MCGOVEN </author> <author> PER BOTHNER </author> <author> KURT CAGLE </author> <author> JAMES LINE </author> <author> GIRIJA VAIDYANATHAN </author> <year> 2003 </year> <price> 49.99 </price> </book> <book category="WEB"> <title lang="en"> LEARNING XML </title> <author> ERICK T ROY </author> <year> 2003 </year> <price> 39.95 </price> </book> </bookstore> Prepared By:Dr.Saranya K.G XML output <u1> { for $x in /bookstore/book/title order by $x return <li>{$x}</li> } </u1> <u1> <li> <title lang="en"> Everyday Italian</title></li> <li><title lang="en">Harry Potter</title></li> <li><title lang="en">Learning XML Start</title></li> <li><title lang="en">XQuery Kick Start</title></li> </u1> <?xml version="1.0" encoding="ISO-8859-1"?> <bookstore> <book category="COOKING"> <title lang="en"> Everyday Italian </title> <author> Giada De Laurenties </author> <year>2005</year> <price>30.00</price> </book> <book category="CHILDREN"> <title lang="en"> Harry Potter </title> <author> J.K. Rowling </author> <year> 2005</year> <price> 29.99 </price> </book> <book category="WEB"> <title lang="en"> XQUERY KICK START </title> <author> JAMES MCGOVEN </author> <author> PER BOTHNER </author> <author> KURT CAGLE </author> <author> JAMES LINE </author> <author> GIRIJA VAIDYANATHAN </author> <year> 2003 </year> <price> 49.99 </price> </book> <book category="WEB"> <title lang="en"> LEARNING XML </title> <author> ERICK T ROY </author> <year> 2003 </year> <price> 39.95 </price> </book> </bookstore> Prepared By:Dr.Saranya K.G
  • 6. 7/9/2019 Prepared By: Dr.Saranya.K.G 6 data() function <u1> [ for $x in /bookstore/book/title order by $x return <li>{data($x)}</li> } </u1> <u1> <li>Everyday Italian</li> <li>Harry Potter</li> <li>Learning XML</li> <li>XQuery Kick Start</li> </u1> <?xml version="1.0" encoding="ISO-8859-1"?> <bookstore> <book category="COOKING"> <title lang="en"> Everyday Italian </title> <author> Giada De Laurenties </author> <year>2005</year> <price>30.00</price> </book> <book category="CHILDREN"> <title lang="en"> Harry Potter </title> <author> J.K. Rowling </author> <year> 2005</year> <price> 29.99 </price> </book> <book category="WEB"> <title lang="en"> XQUERY KICK START </title> <author> JAMES MCGOVEN </author> <author> PER BOTHNER </author> <author> KURT CAGLE </author> <author> JAMES LINE </author> <author> GIRIJA VAIDYANATHAN </author> <year> 2003 </year> <price> 49.99 </price> </book> <book category="WEB"> <title lang="en"> LEARNING XML </title> <author> ERICK T ROY </author> <year> 2003 </year> <price> 39.95 </price> </book> </bookstore> Prepared By:Dr.Saranya K.G if-then-else for $x in /bookstore/book return if ($x/@category="CHILDREN") then <child>{data ($x/title)}</child> else <adult>{data($x/title)}</adult> <adult>Everyday Italian</adult> <child>Harry Potter</child> <adult>Learning XML</adult> <adult>XQuery Kick Start</adult> <?xml version="1.0" encoding="ISO-8859-1"?> <bookstore> <book category="COOKING"> <title lang="en"> Everyday Italian </title> <author> Giada De Laurenties </author> <year>2005</year> <price>30.00</price> </book> <book category="CHILDREN"> <title lang="en"> Harry Potter </title> <author> J.K. Rowling </author> <year> 2005</year> <price> 29.99 </price> </book> <book category="WEB"> <title lang="en"> XQUERY KICK START </title> <author> JAMES MCGOVEN </author> <author> PER BOTHNER </author> <author> KURT CAGLE </author> <author> JAMES LINE </author> <author> GIRIJA VAIDYANATHAN </author> <year> 2003 </year> <price> 49.99 </price> </book> <book category="WEB"> <title lang="en"> LEARNING XML </title> <author> ERICK T ROY </author> <year> 2003 </year> <price> 39.95 </price> </book> </bookstore> Prepared By:Dr.Saranya K.G
  • 7. 7/9/2019 Prepared By: Dr.Saranya.K.G 7 FOR and LET FOR generates a list of bindings of the variable to each element. for $x in (1 to 5) return <test>{$x}</test> <test>1</test> <test>2</test> <test>3</test> <test>4</test> <test>5</test> LET generates a single binding of the variable to the list of elements. let $x := (1 to 5) return <test>{$x}</test> <test> 1 2 2 4 5 </test> Prepared By:Dr.Saranya K.G at for $x at $i in /bookstore/book/title return <book>{$i}.{data($x)}</book> The at keyword can be used to count the iteration. <book>1. Everyday Italian </book> <book>2. Harry Potter </book> <book>3. XQuery Kick Start </book> <book>4. Learning XML </book> <?xml version="1.0" encoding="ISO-8859-1"?> <bookstore> <book category="COOKING"> <title lang="en"> Everyday Italian </title> <author> Giada De Laurenties </author> <year>2005</year> <price>30.00</price> </book> <book category="CHILDREN"> <title lang="en"> Harry Potter </title> <author> J.K. Rowling </author> <year> 2005</year> <price> 29.99 </price> </book> <book category="WEB"> <title lang="en"> XQUERY KICK START </title> <author> JAMES MCGOVEN </author> <author> PER BOTHNER </author> <author> KURT CAGLE </author> <author> JAMES LINE </author> <author> GIRIJA VAIDYANATHAN </author> <year> 2003 </year> <price> 49.99 </price> </book> <book category="WEB"> <title lang="en"> LEARNING XML </title> <author> ERICK T ROY </author> <year> 2003 </year> <price> 39.95 </price> </book> </bookstore> Prepared By:Dr.Saranya K.G
  • 8. 7/9/2019 Prepared By: Dr.Saranya.K.G 8 for $x in (10,20), $y in (100,200) return <test>x={$x} and y={$y}</test> <test>x=10 and y=100</test> <test>x=10 and y=200</test> <test>x=20 and y=100</test> <test>x=20 and y=200</test> for $x at $i in (10,20), $y at $j in (100,200) return <test>{$i}. x={$x} and {$j}. y={$y}</test> <test>1. x=10 and 1. y=100 </test> <test>1. x=10 and 2. y=200 </test> <test>2. x=20 and 1.y=100</test> <test>2. x=20 and 2. y=200</test> Prepared By:Dr.Saranya K.G some, every,in,satisfies for $b in //book where some $p in $b/author satisfies (contains ($p,"in")) return $b/title <title lang="en"> Harry Potter</title> <title lang="en">XQuery Kick Start</title> for $b in //book where every $p in $b/author satisfies (contains($p,"in")) return $b/title <title lang="en">Harry Potter</title> <?xml version="1.0" encoding="ISO-8859-1"?> <bookstore> <book category="COOKING"> <title lang="en"> Everyday Italian </title> <author> Giada De Laurenties </author> <year>2005</year> <price>30.00</price> </book> <book category="CHILDREN"> <title lang="en"> Harry Potter </title> <author> J.K. Rowling </author> <year> 2005</year> <price> 29.99 </price> </book> <book category="WEB"> <title lang="en"> XQUERY KICK START </title> <author> JAMES MCGOVEN </author> <author> PER BOTHNER </author> <author> KURT CAGLE </author> <author> JAMES LINN </author> <author> GIRIJA VAIDYANATHAN </author> <year> 2003 </year> <price> 49.99 </price> </book> <book category="WEB"> <title lang="en"> LEARNING XML </title> <author> ERICK T ROY </author> <year> 2003 </year> <price> 39.95 </price> </book> </bookstore> Prepared By:Dr.Saranya K.G
  • 9. 7/9/2019 Prepared By: Dr.Saranya.K.G 9 sum let $p := for $b in //book return number($b/price) return <s>{$p}</s> <s>30 29.99 49.99 39.95 </s> let $p := for $b in //book return number ($b/price) return <s> {sum($p)}</s> <s> 149.93 </s> <?xml version="1.0" encoding="ISO-8859-1"?> <bookstore> <book category="COOKING"> <title lang="en"> Everyday Italian </title> <author> Giada De Laurenties </author> <year>2005</year> <price>30.00</price> </book> <book category="CHILDREN"> <title lang="en"> Harry Potter </title> <author> J.K. Rowling </author> <year> 2005</year> <price> 29.99 </price> </book> <book category="WEB"> <title lang="en"> XQUERY KICK START </title> <author> JAMES MCGOVEN </author> <author> PER BOTHNER </author> <author> KURT CAGLE </author> <author> JAMES LINE </author> <author> GIRIJA VAIDYANATHAN </author> <year> 2003 </year> <price> 49.99 </price> </book> <book category="WEB"> <title lang="en"> LEARNING XML </title> <author> ERICK T ROY </author> <year> 2003 </year> <price> 39.95 </price> </book> </bookstore> Prepared By:Dr.Saranya K.G Sequence let $p := //book/price let $y := //book/year return ($p,$y) <price>30.00</price> <price>29.99</price> <price>49.99</price> <price>39.95</price> <year>2005</year> <year>2005</year> <year>2003</year> <year>2003</year> <?xml version="1.0" encoding="ISO-8859-1"?> <bookstore> <book category="COOKING"> <title lang="en"> Everyday Italian </title> <author> Giada De Laurenties </author> <year>2005</year> <price>30.00</price> </book> <book category="CHILDREN"> <title lang="en"> Harry Potter </title> <author> J.K. Rowling </author> <year> 2005</year> <price> 29.99 </price> </book> <book category="WEB"> <title lang="en"> XQUERY KICK START </title> <author> JAMES MCGOVEN </author> <author> PER BOTHNER </author> <author> KURT CAGLE </author> <author> JAMES LINE </author> <author> GIRIJA VAIDYANATHAN </author> <year> 2003 </year> <price> 49.99 </price> </book> <book category="WEB"> <title lang="en"> LEARNING XML </title> <author> ERICK T ROY </author> <year> 2003 </year> <price> 39.95 </price> </book> </bookstore>Prepared By:Dr.Saranya K.G
  • 10. 7/9/2019 Prepared By: Dr.Saranya.K.G 10 union //book/(price union year) //book/(price | title) <year>2005</year> <price>30.00</price> <year>2005</yera> <price>29.99</price> <year>2003</year> <price>49.99</price> <year>2003</year> <?xml version="1.0" encoding="ISO-8859-1"?> <bookstore> <book category="COOKING"> <title lang="en"> Everyday Italian </title> <author> Giada De Laurenties </author> <year>2005</year> <price>30.00</price> </book> <book category="CHILDREN"> <title lang="en"> Harry Potter </title> <author> J.K. Rowling </author> <year> 2005</year> <price> 29.99 </price> </book> <book category="WEB"> <title lang="en"> XQUERY KICK START </title> <author> JAMES MCGOVEN </author> <author> PER BOTHNER </author> <author> KURT CAGLE </author> <author> JAMES LINE </author> <author> GIRIJA VAIDYANATHAN </author> <year> 2003 </year> <price> 49.99 </price> </book> <book category="WEB"> <title lang="en"> LEARNING XML </title> <author> ERICK T ROY </author> <year> 2003 </year> <price> 39.95 </price> </book> </bookstore> Prepared By:Dr.Saranya K.G intersect let $b := //book return $b[year="2005"] intersect $b[number(price)>=30] <book category="COOKING"> <title lang="en"> Everyday Italian </title> <author> Giada De Laurentiis</author> <yer>2005</year> <price>30.00</price> </book> <?xml version="1.0" encoding="ISO-8859-1"?> <bookstore> <book category="COOKING"> <title lang="en"> Everyday Italian </title> <author> Giada De Laurenties </author> <year>2005</year> <price>30.00</price> </book> <book category="CHILDREN"> <title lang="en"> Harry Potter </title> <author> J.K. Rowling </author> <year> 2005</year> <price> 29.99 </price> </book> <book category="WEB"> <title lang="en"> XQUERY KICK START </title> <author> JAMES MCGOVEN </author> <author> PER BOTHNER </author> <author> KURT CAGLE </author> <author> JAMES LINE </author> <author> GIRIJA VAIDYANATHAN </author> <year> 2003 </year> <price> 49.99 </price> </book> <book category="WEB"> <title lang="en"> LEARNING XML </title> <author> ERICK T ROY </author> <year> 2003 </year> <price> 39.95 </price> </book> </bookstore> Prepared By:Dr.Saranya K.G
  • 11. 7/9/2019 Prepared By: Dr.Saranya.K.G 11 except //book/(* except author) <title lang="en">Everyday Italian</title> <year>2005</year> <price>30.00</price> <title lang="en">Harry Potter</title> <year>2005</year> <price>29.99</price> <title lang="en">XQuery Kick Start</title> <year>2003</year> <price>49.99</price> <title lang="en"> Learning XML </title> <year>2003</year> <price>39.95</price> <?xml version="1.0" encoding="ISO-8859-1"?> <bookstore> <book category="COOKING"> <title lang="en"> Everyday Italian </title> <author> Giada De Laurenties </author> <year>2005</year> <price>30.00</price> </book> <book category="CHILDREN"> <title lang="en"> Harry Potter </title> <author> J.K. Rowling </author> <year> 2005</year> <price> 29.99 </price> </book> <book category="WEB"> <title lang="en"> XQUERY KICK START </title> <author> JAMES MCGOVEN </author> <author> PER BOTHNER </author> <author> KURT CAGLE </author> <author> JAMES LINE </author> <author> GIRIJA VAIDYANATHAN </author> <year> 2003 </year> <price> 49.99 </price> </book> <book category="WEB"> <title lang="en"> LEARNING XML </title> <author> ERICK T ROY </author> <year> 2003 </year> <price> 39.95 </price> </book> </bookstore> Prepared By:Dr.Saranya K.G number(arg) Returns the numeric value of the argument abs(num) Returns the absolute value of the argument ceiling(num) Returns the smallest integer that is greater than the number argument floor(num) Returns the largest integer that is not greater than the number argument round(num) Rounds the number argument to the nearest integer. Functions on Numeric Values Prepared By:Dr.Saranya K.G
  • 12. 7/9/2019 Prepared By: Dr.Saranya.K.G 12 string(arg) Returns the string value of the argument compare(comp1,comp2) Returns -1 if comp1 is less than comp2, 0 if comp1 is equal to comp2, or 1 if comp1 is greater than comp2 concat(string,string,..) Returns the concatenation of the strings. string-join((string,string,…),sep) Retruns a string created by concatenating the string arguments and using the sep argument as the separator substring(string,start,len) substring(string,start) Returns the substring from the start position to the specified length. Index of the first character is 1. If length is omitted it returns the substring from the start position to the end. string-length(string) string-length() Returns the length of the specified string. If there is no string argument it returns the length of the string value of the current node. normalize-space(string) normalize-space() Removes leading and trailing spaces from the specified string and replaces all internal sequences of white space with one and returns the result. If there is no string argument it does the same on the current node. Functions on Strings1 Prepared By:Dr.Saranya K.G upper-case(string) Converts the string argument to upper-case lower-case(string) Converts the string argument to lower-case contains(string1,string2) Returns true if string1 contains string2. Otherwise it returns false. starts-with (string1,string2) Returns true if string1 starts with string2 Otherwise it returns false. ends-with(string1,string2) Returns true if string1 ends with string2 Otherwise it returns false. substring-before(string1,string2) Returns the start of string 1 before string2 occurs in it substring-after(string1,string2) Returns the remainder of string1 after string2 occurs in it. matches(string,pattern) Returns true if the string argument matches the pattern. Otherwise, it returns false. replace(string,pattern,replace) Returns a string that is created by replacing the given pattern with the replace argument. FUNCTIONS ON STRINGS2 Prepared By:Dr.Saranya K.G
  • 13. 7/9/2019 Prepared By: Dr.Saranya.K.G 13 count((item,item,…)) Returns the count of the nodes avg((arg,arg,..)) Returns the average of the argument values max((arg,arg,…)) Returns the argument that is greater than the others min((arg,arg,….)) Returns the argument that is less than the others sum(arg,arg,…) Returns the sum of the numeric value of each node in the specified node-set. Aggregate Functions Prepared By:Dr.Saranya K.G