SlideShare ist ein Scribd-Unternehmen logo
1 von 13
Downloaden Sie, um offline zu lesen
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

Weitere ähnliche Inhalte

Ähnlich wie Xquery1

Ähnlich wie Xquery1 (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
 

Mehr von Dr.Saranya K.G

Mehr von 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
 

Kürzlich hochgeladen

AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdfankushspencer015
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performancesivaprakash250
 
Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptDineshKumar4165
 
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Bookingroncy bisnoi
 
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...SUHANI PANDEY
 
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptxBSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptxfenichawla
 
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
 
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordAsst.prof M.Gokilavani
 
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...ranjana rawat
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations120cr0395
 
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756dollysharma2066
 
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
 
Unit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdfUnit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdfRagavanV2
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxAsutosh Ranjan
 
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...Call Girls in Nagpur High Profile
 
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingUNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingrknatarajan
 

Kürzlich hochgeladen (20)

AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdf
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performance
 
Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.ppt
 
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Walvekar Nagar Call Me 7737669865 Budget Friendly No Advance Booking
 
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
 
NFPA 5000 2024 standard .
NFPA 5000 2024 standard                                  .NFPA 5000 2024 standard                                  .
NFPA 5000 2024 standard .
 
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptxBSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
 
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...
 
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
 
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations
 
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
 
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)
 
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
 
Unit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdfUnit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdf
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptx
 
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
 
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
 
(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
 
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingUNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
 

Xquery1

  • 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