Download as pdf or txt
Download as pdf or txt
You are on page 1of 40

Web Data Management (IT701-N) 20BEIT30041

KADI SARVA VISHWAVIDYALAYA


LDRP INSTITUTE OF TECHNOLOGY AND RESEARCH

GANDHINAGAR

Department of
Computer Engineering and
Information Technology

Subject : Web Data

Management(IT701-N)

Laboratory Manual

Prepared By

Name: VEDANT KHAMAR

Enrollment No. :20BEIT30041

Class: 7 IT-I

LDRP-ITR 1
Web Data Management (IT701-N) 20BEIT30041

LDRP INSTITUTE OF TECHNOLOGY AND RESEARCH

GANDHINAGAR

DEPARTMENT OF COMPUTER ENGINEERING


&

INFORMATION TECHNOLOGY

CERTIFICATE

Mr. VEDANT KHAMAR of 7th IT-I, Enrollment No.: 20BEIT30041


has satisfactorily completed his/her term work in Web Data
Management (IT701-N) for the term ending in Nov-2023.

Date: 14/10/23

Yogesh Vaghela Dr. Mehul Barot

Subject Coordinator I\C HOD-IT

LDRP-ITR 2
Web Data Management (IT701-N) 20BEIT30041

Index

Sr. Name of Experiment Date Signature


No.
1 Create an XML file defining an article in newspaper.
2 Create an XML file containing list of students. Also create style sheet file to
display list in an HTML format.
3 Create an XML file containing list of students. Using XPath display followi
ng information
• Information of a student with ID No : 101
• All the student in the sorted order according to their CGPA
4 Create an XForm to collect information from staff member regarding their
publications.
Details like Year of Publication, National/International,
Title, Conference/Journal etc.
5 From the above gathered information, using
Query find out the number of publication in a specific year.
6 Demonstrate the use of AJAX.
7 Study of XMLSPY tool.
8 Create an RSS for the events occurring in your institute.
9 Write a program to read the articles in RSS created in above practical.
10 Study of RDF (Resource Description Framework)

LDRP-ITR
3
Web Data Management (IT701-N) 20BEIT30041

Practical-1

Aim: Create a large XML Dataset.


<?xml version="1.0" encoding="UTF-8"?><mobile-apps>
<uber-
system>
<person>
<firstname>Pandya</firstname>
<lastname>Harsh</lastname>
<gender>Male</gender>

</person>
<email>aquastyle0909@gmail.com</email>
<user-rating>4.5</user-rating>
<completed-rides>10</completed-rides>
<upcoming-rides>1</upcoming-rides>
<image
url="https://images.app.goo.gl/stkiXhKomLW3gWvz8">Logo</image>

<payment-methods>
<method-1>Debit card</method-1>
<method-1>Credit card</method-1>
<method-1>Online Payment Wallets</method-1>
</payment-methods>
<address>

<home-address>Home</home-address>
<work-address>Work</work-address>
</address>
<Security>Password and 2 factor authentication</Security>
<maps-used>Google maps</maps-used>
<app-version>4.346.10006</app-version>

LDRP-ITR
4
Web Data Management (IT701-N) 20BEIT30041

</uber-system>
<keep-notes>
<person>
<firstname>Raj</firstname>
<lastname>Patel</lastname>
</person>

<email>rajp23232@hotmail.com</email>
<notes>34</notes>
<labels>
<android>Android course</android>

<java>Java course</java>
<python>Python course</python>
<JavaScript>Java script</JavaScript>
<Ruby>Ruby course</Ruby>
</labels>
<archived-notes>2</archived-notes>
<pinned-notes>1</pinned-notes>
<notes-in-bin>3</notes-in-bin>

<reminder>
<reminder-1>Attend a seminar</reminder-1>

<reminder-2>Set up node applicartion</reminder-2>


</reminder>
<app-version>5.20.491.01.40</app-version>
</keep-notes></mobile-apps>

LDRP-ITR
5
Web Data Management (IT701-N) 20BEIT30041

Practical-2
Aim: Create a DTD file for large XML Dataset.

<?xml encoding="UTF-8"?>

<!ELEMENT mobile-apps (uber-system,keep-notes)>

<!ATTLIST mobile-apps xmlns


CDATA #FIXED ''>

<!ELEMENT uber-system (person,email,user-rating,completed-rides,


upcoming-rides,image,payment-methods,address, Security,maps-used,app-
version)>

<!ATTLIST uber-system
xmlns CDATA #FIXED ''>

<!ELEMENT keep-notes (person,email,notes,labels,archived-notes,


pinned-notes,notes-in-bin,reminder,app-version)>

<!ATTLIST keep-notes xmlns


CDATA #FIXED ''>

<!ELEMENT user-rating (#PCDATA)>


<!ATTLIST user-rating xmlns CDATA #FIXED ''>

<!ELEMENT completed-rides (#PCDATA)>


<!ATTLIST completed-rides xmlns CDATA #FIXED ''>

<!ELEMENT upcoming-rides (#PCDATA)>


<!ATTLIST upcoming-rides xmlns CDATA #FIXED ''>

<!ELEMENT image (#PCDATA)>


<!ATTLIST image
xmlns CDATA #FIXED '' url
CDATA #REQUIRED>

LDRP-ITR
6
Web Data Management (IT701-N) 20BEIT30041

<!ELEMENT payment-methods (method-1)+>


<!ATTLIST payment-methods
xmlns CDATA #FIXED ''>

<!ELEMENT address (home-address,work-address)>


<!ATTLIST address
xmlns CDATA #FIXED ''>

<!ELEMENT Security (#PCDATA)>


<!ATTLIST Security
xmlns CDATA #FIXED ''>
<!ELEMENT maps-used (#PCDATA)>
<!ATTLIST maps-used xmlns CDATA #FIXED ''>

<!ELEMENT notes (#PCDATA)>


<!ATTLIST notes
xmlns CDATA #FIXED ''>

<!ELEMENT labels (android,java,python,JavaScript,Ruby)>


<!ATTLIST labels
xmlns CDATA #FIXED ''>

<!ELEMENT archived-notes (#PCDATA)>


<!ATTLIST archived-notes
xmlns CDATA #FIXED ''>

<!ELEMENT pinned-notes (#PCDATA)>


<!ATTLIST pinned-notes
xmlns CDATA #FIXED ''>

<!ELEMENT notes-in-bin (#PCDATA)>


<!ATTLIST notes-in-bin
xmlns CDATA #FIXED ''>

<!ELEMENT reminder (reminder-1,reminder-2)>


<!ATTLIST reminder
xmlns CDATA #FIXED ''>

LDRP-ITR
7
Web Data Management (IT701-N) 20BEIT30041

<!ELEMENT method-1 (#PCDATA)>


<!ATTLIST method-1
xmlns CDATA #FIXED ''>

<!ELEMENT home-address (#PCDATA)>


<!ATTLIST home-address xmlns CDATA #FIXED ''>

<!ELEMENT work-address (#PCDATA)>


<!ATTLIST work-address
xmlns CDATA #FIXED ''>

<!ELEMENT android (#PCDATA)>


<!ATTLIST android
xmlns CDATA #FIXED ''>

<!ELEMENT java (#PCDATA)>


<!ATTLIST java
xmlns CDATA #FIXED ''>

<!ELEMENT python (#PCDATA)>

<!ATTLIST python
xmlns CDATA #FIXED ''>

<!ELEMENT JavaScript (#PCDATA)>


<!ATTLIST JavaScript
xmlns CDATA #FIXED ''>

<!ELEMENT Ruby (#PCDATA)>


<!ATTLIST Ruby
xmlns CDATA #FIXED ''>

<!ELEMENT reminder-1 (#PCDATA)>


<!ATTLIST reminder-1
xmlns CDATA #FIXED ''>

<!ELEMENT reminder-2 (#PCDATA)>


<!ATTLIST reminder-2
xmlns CDATA #FIXED ''>
LDRP-ITR
8
Web Data Management (IT701-N) 20BEIT30041

<!ELEMENT person (firstname,lastname,gender?)>


<!ATTLIST person
xmlns CDATA #FIXED ''>
<!ELEMENT firstname (#PCDATA)>
<!ATTLIST firstname
xmlns CDATA #FIXED ''>

<!ELEMENT lastname (#PCDATA)>


<!ATTLIST lastname
xmlns CDATA #FIXED ''>

<!ELEMENT gender (#PCDATA)>


<!ATTLIST gender
xmlns CDATA #FIXED ''>

<!ELEMENT email (#PCDATA)>


<!ATTLIST email
xmlns CDATA #FIXED ''>

<!ELEMENT app-version (#PCDATA)>


<!ATTLIST app-version
xmlns CDATA #FIXED ''>

LDRP-ITR
9
Web Data Management (IT701-N) 20BEIT30041

Practical-3

Aim: Create a XSD file for large XML Dataset.

<?xml version="1.0" encoding="UTF-8"?>


<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified">

<xs:element name="mobile-apps">
<xs:complexType>

<xs:sequence>
<xs:element ref="uber-system"/>
<xs:element ref="keep-notes"/>
</xs:sequence>

</xs:complexType>
</xs:element>

<xs:element name="uber-system">
<xs:complexType>
<xs:sequence>
<xs:element ref="person"/>
<xs:element ref="email"/>
<xs:element ref="user-rating"/>

<xs:element ref="completed-rides"/>
<xs:element ref="upcoming-rides"/>

<xs:element ref="image"/>
<xs:element ref="payment-methods"/>
<xs:element ref="address"/>
<xs:element ref="Security"/>

<xs:element ref="maps-used"/>
<xs:element ref="app-version"/>
</xs:sequence>
</xs:complexType>
LDRP-ITR
10
Web Data Management (IT701-N) 20BEIT30041

</xs:element>
<xs:element name="user-rating" type="xs:decimal"/>
<xs:element name="completed-rides" type="xs:integer"/>
<xs:element name="upcoming-rides" type="xs:integer"/>
<xs:element name="image">
<xs:complexType>

<xs:simpleContent>
<xs:extension base="xs:NCName">
<xs:attribute name="url" use="required" type="xs:anyURI"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
<xs:element name="payment-methods">
<xs:complexType>
<xs:sequence>
<xs:element maxOccurs="unbounded" ref="method-1"/>
</xs:sequence>

</xs:complexType>
</xs:element>
<xs:element name="method-1" type="xs:string"/>
<xs:element name="address">
<xs:complexType>
<xs:sequence>

<xs:element ref="home-address"/>
<xs:element ref="work-address"/>
</xs:sequence>
</xs:complexType>

</xs:element>
<xs:element name="home-address" type="xs:NCName"/>
<xs:element name="work-address" type="xs:NCName"/>
LDRP-ITR
11
Web Data Management (IT701-N) 20BEIT30041

<xs:element name="Security" type="xs:string"/>


<xs:element name="maps-used" type="xs:string"/>
<xs:element name="keep-notes">

<xs:complexType>
<xs:sequence>
<xs:element ref="person"/>
<xs:element ref="email"/>
<xs:element ref="notes"/>
<xs:element ref="labels"/>
<xs:element ref="archived-notes"/>
<xs:element ref="pinned-notes"/>
<xs:element ref="notes-in-bin"/>
<xs:element ref="reminder"/>
<xs:element ref="app-version"/>
</xs:sequence>
</xs:complexType>
</xs:element>

<xs:element name="notes" type="xs:integer"/>


<xs:element name="labels">
<xs:complexType>
<xs:sequence>
<xs:element ref="android"/>
<xs:element ref="java"/>
<xs:element ref="python"/>
<xs:element ref="JavaScript"/>
<xs:element ref="Ruby"/>
</xs:sequence>

</xs:complexType>
</xs:element>
<xs:element name="android" type="xs:string"/>
LDRP-ITR
12
Web Data Management (IT701-N) 20BEIT30041

<xs:element name="java" type="xs:string"/>

<xs:element name="python" type="xs:string"/>


<xs:element name="JavaScript" type="xs:string"/>

<xs:element name="Ruby" type="xs:string"/>


<xs:element name="archived-notes" type="xs:integer"/>
<xs:element name="pinned-notes" type="xs:integer"/>
<xs:element name="notes-in-bin" type="xs:integer"/>
<xs:element name="reminder">
<xs:complexType>

<xs:sequence>
<xs:element ref="reminder-1"/>
<xs:element ref="reminder-2"/>
</xs:sequence>

</xs:complexType>
</xs:element>
<xs:element name="reminder-1" type="xs:string"/>
<xs:element name="reminder-2" type="xs:string"/>
<xs:element name="person">
<xs:complexType>

<xs:sequence>
<xs:element ref="firstname"/>
<xs:element ref="lastname"/>
<xs:element minOccurs="0" ref="gender"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="firstname" type="xs:NCName"/>
<xs:element name="lastname" type="xs:NCName"/>
<xs:element name="gender" type="xs:NCName"/>
<xs:element name="email" type="xs:string"/>
<xs:element name="app-version" type="xs:NMTOKEN"/>
LDRP-ITR
13
Web Data Management (IT701-N) 20BEIT30041

</xs:schema>

LDRP-ITR
14
Web Data Management (IT701-N) 20BEIT30041

Practical-4

Aim: Create a XSL Script for large XML Dataset to display data different
way.

XSL File:

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="employee">

<html>

<body>

<h1>Employee Data</h1>

<table border="1px solid black">

<tr>

<td>First Name</td>

<td>Last Name</td>

<td>Email</td>

<td>City</td>

<td>Age</td>

<td>Birth Date</td>

<td>Joining Date</td>

<td>Department</td>

<td>Job Post</td>
LDRP-ITR
15
Web Data Management (IT701-N) 20BEIT30041

</tr>
<xsl:for-each select="id">

<tr>

<td><xsl:value-of select="firstname" /></td>

<td><xsl:value-of select="lastname" /></td>

<td><xsl:value-of select="email" /></td>

<td><xsl:value-of select="address" /></td>

<td><xsl:value-of select="age" /></td>

<td><xsl:value-of select="bdate" /></td>

<td><xsl:value-of select="join" /></td>

<xsl:for-each select="department">

<xsl:choose>

<xsl:when test="@type = 'research'">

<td><xsl:value-of select="." /></td>

<td>Researcher</td>

</xsl:when>

<xsl:when test="@type = 'coding'">

<td><xsl:value-of select="." /></td>

<td>Coder</td>

</xsl:when>

</xsl:choose>

</xsl:for-each>

</tr>

LDRP-ITR
16
Web Data Management (IT701-N) 20BEIT30041

</xsl:for-each>

</table>

</body>
</html>

</xsl:template>

</xsl:stylesheet>

XML File:

<?xml version="1.0" standalone="no"?>

<?xml-stylesheet type="text/xsl" href="p1.xsl"?>

<employee>

<id>

<firstname>Purvesh</firstname>

<lastname>Patel</lastname>

<email>purvesh@gmail.com</email>

<address>Ahmedabad</address>

<age>21</age>

<bdate>1999-11-05</bdate>

<join>2019-09-28</join>

<department type="research">RnD</department>

</id>

LDRP-ITR
17
Web Data Management (IT701-N) 20BEIT30041

<id>

<firstname>Pari</firstname>

<lastname>Nimavat</lastname>

<email>pari@gmail.com</email>

<address>Ahmedabad</address>
<age>20</age>

<bdate>2000-04-28</bdate>

<join>2019-09-28</join>

<department type="research">RnD</department>

</id>

<id>

<firstname>Umang</firstname>

<lastname>Patel</lastname>

<email>umang@gmail.com</email>

<address>Mumbai</address>

<age>21</age>

<bdate>1999-11-25</bdate>

<join>2019-09-28</join>

<department type="coding">Development</department>

</id>

<id>

<firstname>Harsh</firstname>

LDRP-ITR
18
Web Data Management (IT701-N) 20BEIT30041

<lastname>Pandya</lastname>

<email>harsh@gmail.com</email>

<address>Ahmedabad</address>

<age>20</age>

<bdate>2000-09-07</bdate>

<join>2019-09-28</join>

<department type="coding">Tester</department>
</id>

<id>

<firstname>Milan</firstname>

<lastname>Patel</lastname>

<email>milan@gmail.com</email>

<address>Mumbai</address>

<age>21</age>

<bdate>1999-04-15</bdate>

<join>2019-09-28</join>

<department type="coding">Tester</department>

</id>

</employee>

LDRP-ITR
19
Web Data Management (IT701-N) 20BEIT30041

Practical-5

Aim: Create a Xpath statement to fetch content of XML file.

XML File:

<?xml version="1.0" standalone="no"?>

<?xml-stylesheet type="text/xsl" href="p1.xsl"?>

<employee>

<id>

<firstname>Purvesh</firstname>

<lastname>Patel</lastname>

<email>purvesh@gmail.com</email>

<address>Ahmedabad</address>

<age>21</age>

<bdate>1999-11-05</bdate>

<join>2019-09-28</join>

<department type="research">RnD</department>

</id>

<id>

<firstname>Pari</firstname>

<lastname>Nimavat</lastname>

<email>pari@gmail.com</email>

<address>Ahmedabad</address>

<age>20</age>
LDRP-ITR
20
Web Data Management (IT701-N) 20BEIT30041

<bdate>2000-04-28</bdate>

<join>2019-09-28</join>
<department type="research">RnD</department>

</id>

<id>

<firstname>Umang</firstname>

<lastname>Patel</lastname>

<email>umang@gmail.com</email>

<address>Mumbai</address>

<age>21</age>

<bdate>1999-11-25</bdate>

<join>2019-09-28</join>

<department type="coding">Development</department>

</id>

<id>

<firstname>Harsh</firstname>

<lastname>Pandya</lastname>

<email>harsh@gmail.com</email>

<address>Ahmedabad</address>

<age>20</age>

<bdate>2000-09-07</bdate>

<join>2019-09-28</join>

LDRP-ITR
21
Web Data Management (IT701-N) 20BEIT30041

<department type="coding">Tester</department>

</id>

<id>
<firstname>Milan</firstname>

<lastname>Patel</lastname>

<email>milan@gmail.com</email>

<address>Mumbai</address>

<age>21</age>

<bdate>1999-04-15</bdate>

<join>2019-09-28</join>

<department type="coding">Tester</department>

</id>

</employee>

Xpath statements with queries:

1) Employee first-names start with ‘P’.


//firstname[contains(text(),"P")]

2) Employee last-names is ‘Patel’.


//lastname[contains(text(),"Patel")]

3) Employees use gmail as a mail-server.


//gmail[contains(text(),"gmail.com")]

4) The Employee's location is ‘Ahmedabad’.


LDRP-ITR
22
Web Data Management (IT701-N) 20BEIT30041

//address[contains(text(),"Ahmedabad")]

5) The Employee's location is ‘Mumbai’.


//address[contains(text(),"Mumbai")]

LDRP-ITR
23
Web Data Management (IT701-N) 20BEIT30041

Practical-6

Aim:Create a Xpath statement to demonstrate use of Axes in XML file.

XMLfile:

<bookstore>
<bookcategory="fiction">
<title>TheGreatGatsby</title>
<author>F.ScottFitzgerald</author>
<price>10.99</price>
</book>
<bookcategory="non-fiction">
<title>TheElementsofStyle</title>
<author>WilliamStrunkJr.</author>
<author>E.B.White</author>
<price>9.99</price>
</book>
</bookstore>

If you wanted to select only the "author" elements that are direct children of the
"book" elements, you could use the "child" axis, like this:
/bookstore/book/author

LDRP-ITR
24
Web Data Management (IT701-N) 20BEIT30041

Practical-7

Aim: Create a Xpath statement to use in build function.

XML File:
<books>
<book>
<title>TheGreatGatsby</title>
<author>F.ScottFitzgerald</author>
<year>1925</year>
<publisher>CharlesScribner'sSons</publisher>
</book>
<book>
<title>ToKillaMockingbird</title>
<author>HarperLee</author>
<year>1960</year>
<publisher>J.B.Lippincott &Co.</publisher>
</book>
<!--morebooks-->
</books>
You could use the following XPath statement to select all the "book" elements in
the XMLfile:
/books/book

LDRP-ITR
25
Web Data Management (IT701-N) 20BEIT30041

Practical-8

Aim: Write a Xquery (FLOWR) to retrieve content from single file.

XML File:
<?xml version="1.0"?>
<catalog>
<book id="bk101">
<author>Gambardella, Matthew</author>
<title>XML Developer's Guide</title>
<genre>Computer</genre>
<price>44.95</price>
<publish_date>2000-10-01</publish_date>
<description>An in-depth look at creating applications with
XML.</description>
</book>
<book id="bk102">
<author>Ralls, Kim</author>
<title>Midnight Rain</title>
<genre>Fantasy</genre>
<price>5.95</price>
<publish_date>2000-12-16</publish_date>
<description>A former architect battles corporate zombies, an evil
sorceress, and her own childhood to become queen of the
world.</description>
</book>
<book id="bk103">
<author>Corets, Eva</author>
<title>Maeve Ascendant</title>
<genre>Fantasy</genre>
<price>5.95</price>
<publish_date>2000-11-17</publish_date>
LDRP-ITR
26
Web Data Management (IT701-N) 20BEIT30041

<description>After the collapse of a nanotechnology society in


England, the young survivors lay the foundation for a new
society.</description>
</book>
<book id="bk104">
<author>Corets, Eva</author>
<title>Oberon's Legacy</title>
<genre>Fantasy</genre>
<price>5.95</price>
<publish_date>2001-03-10</publish_date>
<description>In post-apocalypse England, the mysterious agent
known only as Oberon helps to create a new life for the
inhabitants of London. Sequel to Maeve
Ascendant.</description>
</book>
<book id="bk105">
<author>Corets, Eva</author>
<title>The Sundered Grail</title>
<genre>Fantasy</genre>
<price>5.95</price>
<publish_date>2001-09-10</publish_date>
<description>The two daughters of Maeve, half-sisters, battle one
another for control of England. Sequel to Oberon's
Legacy.</description>
</book>
<book id="bk106">
<author>Randall, Cynthia</author>
<title>Lover Birds</title>
<genre>Romance</genre>
<price>4.95</price>
<publish_date>2000-09-02</publish_date>
<description>When Carla meets Paul at an ornithology conference,
tempers fly as feathers get ruffled.</description>
</book>
LDRP-ITR
27
Web Data Management (IT701-N) 20BEIT30041

<book id="bk107">
<author>Thurman, Paula</author>
<title>Splish Splash</title>
<genre>Romance</genre>
<price>4.95</price>
<publish_date>2000-11-02</publish_date>
<description>A deep sea diver finds true love twenty thousand
leagues beneath the sea.</description>
</book>
<book id="bk108">
<author>Knorr, Stefan</author>
<title>Creepy Crawlies</title>
<genre>Horror</genre>
<price>4.95</price>
<publish_date>2000-12-06</publish_date>
<description>An anthology of horror stories about roaches, centipedes,
scorpions and other insects.</description>
</book>
<book id="bk109">
<author>Kress, Peter</author>
<title>Paradox Lost</title>
<genre>Science Fiction</genre>
<price>6.95</price>
<publish_date>2000-11-02</publish_date>
<description>After an inadvertant trip through a Heisenberg
Uncertainty Device, James Salway discovers the problems of being
quantum.</description>
</book>
<book id="bk110">
<author>O'Brien, Tim</author>
<title>Microsoft .NET: The Programming Bible</title>
<genre>Computer</genre>
<price>36.95</price>
<publish_date>2000-12-09</publish_date>
LDRP-ITR
28
Web Data Management (IT701-N) 20BEIT30041

<description>Microsoft's .NET initiative is explored in detail in this deep


programmer's reference.</description>
</book>
<book id="bk111">
<author>O'Brien, Tim</author>
<title>MSXML3: A Comprehensive Guide</title>
<genre>Computer</genre>
<price>36.95</price>
<publish_date>2000-12-01</publish_date>
<description>The Microsoft MSXML3 parser is covered in detail, with
attention to XML DOM interfaces, XSLT processing, SAX and
more.</description>
</book>
</catalog>
Query 1: For and return
for $i in /catalog/book/title return
<title>{$i}</title>
Output:
<title>XML Developer's Guide</title>
<title>Midnight Rain</title>
<title>Maeve Ascendant</title>
<title>Oberon's Legacy</title>
<title>The Sundered Grail</title>
<title>Lover Birds</title>
<title>Splish Splash</title>
<title>Creepy Crawlies</title>
<title>Paradox Lost</title>
<title>Microsoft .NET: The Programming Bible</title>
<title>MSXML3: A Comprehensive Guide</title>
<title>Visual Studio 7: A Comprehensive Guide</title>

LDRP-ITR
29
Web Data Management (IT701-N) 20BEIT30041

Query 2: Let, For and return


distinct-values(
for $i in /catalog/book let
$n := $i/genre
return <genre>{$n}</genre>
)
Output:
<genre>Computer</genre>
<genre>Fantasy</genre>
<genre>Romance</genre>
<genre>Horror</genre>
<genre>Science Fiction</genre>

Query 3: Let, For, where and return


distinct-values(
for $i in /catalog/book let
$n := $i/title
where $i/genre = 'Computer' return
<title>{$n}</title>
)
Output:
<title>XML Developer's Guide</title>
<title>Microsoft .NET: The Programming Bible</title>
<title>MSXML3: A Comprehensive Guide</title>
<title>Visual Studio 7: A Comprehensive Guide</title>

Query 4: Let, For, where, order and return


distinct-values(
LDRP-ITR
30
Web Data Management (IT701-N) 20BEIT30041

for $i in /catalog/book let


$n := $i/title
where $i/genre = 'Computer' order
by $n
return <title>{$n}</title>
)
Output:
<title>Microsoft .NET: The Programming Bible</title>
<title>MSXML3: A Comprehensive Guide</title>
<title>Visual Studio 7: A Comprehensive Guide</title>
<title>XML Developer's Guide</title>

LDRP-ITR
31
Web Data Management (IT701-N) 20BEIT30041

Practical-9

Aim :Write a Xquery (FLOWR) to retrieve content from multiple files.

Books.xml
<?xml version="1.0"?>
<catalog>
<book id="bk101">
<author>Gambardella, Matthew</author>
<title>XML Developer's Guide</title>
<genre>Computer</genre>
<price>44.95</price>
</book>
<book id="bk102">
<author>Ralls, Kim</author>
<title>Midnight Rain</title>
<genre>Fantasy</genre>
<price>5.95</price>
</book>
<book id="bk103">
<author>Corets, Eva</author>
<title>Maeve Ascendant</title>
<genre>Fantasy</genre>
<price>5.95</price>
</book>
<book id="bk104">
<author>Corets, Eva</author>
<title>Oberon's Legacy</title>
<genre>Fantasy</genre>
<price>5.95</price>
</book>
<book id="bk105">
<author>Corets, Eva</author>
LDRP-ITR
32
Web Data Management (IT701-N) 20BEIT30041

<title>The Sundered Grail</title>


<genre>Fantasy</genre>
<price>5.95</price>
</book>

<book id="bk106">
<author>Randall, Cynthia</author>
<title>Lover Birds</title>
<genre>Romance</genre>
<price>4.95</price>
</book>
<book id="bk107">
<author>Thurman, Paula</author>
<title>Splish Splash</title>
<genre>Romance</genre>
<price>4.95</price>
</book>
<book id="bk108">
<author>Knorr, Stefan</author>
<title>Creepy Crawlies</title>
<genre>Horror</genre>
<price>4.95</price>
</book>
<book id="bk109">
<author>Kress, Peter</author>
<title>Paradox Lost</title>
<genre>Science Fiction</genre>
<price>6.95</price>
</book>
<book id="bk110">
<author>O'Brien, Tim</author>
<title>Microsoft .NET: The Programming Bible</title>
<genre>Computer</genre>
<price>36.95</price>
LDRP-ITR
33
Web Data Management (IT701-N) 20BEIT30041

</book>
<book id="bk111">
<author>O'Brien, Tim</author>
<title>MSXML3: A Comprehensive Guide</title>
<genre>Computer</genre>
<price>36.95</price>
</book>
<book id="bk112">
<author>Galos, Mike</author>
<title>Visual Studio 7: A Comprehensive Guide</title>
<genre>Computer</genre>
<price>49.95</price>
</book>
</catalog>
Book_info.xml
<?xml version="1.0"?>
<catalog>
<book id="bk101">
<title>XML Developer's Guide</title>
<publish_date>2000-10-01</publish_date>
<description>An in-depth look at creating applications with
XML.</description>
</book>
<book id="bk102">
<title>Midnight Rain</title>
<publish_date>2000-12-16</publish_date>
<description>A former architect battles corporate zombies, an evil
sorceress, and her own childhood to become queen of the
world.</description>
</book>
<book id="bk103">
<title>Maeve Ascendant</title>
<publish_date>2000-11-17</publish_date>

LDRP-ITR
34
Web Data Management (IT701-N) 20BEIT30041

<description>After the collapse of a nanotechnology society in


England, the young survivors lay the foundation for a new
society.</description>
</book>
<book id="bk104">
<title>Oberon's Legacy</title>
<publish_date>2001-03-10</publish_date>
<description>In post-apocalypse England, the mysterious agent known
only as Oberon helps to create a new life for the inhabitants of London.
Sequel to Maeve Ascendant.</description>
</book>
<book id="bk105">
<title>The Sundered Grail</title>
<publish_date>2001-09-10</publish_date>
<description>The two daughters of Maeve, half-sisters, battle one
another for control of England. Sequel to Oberon's
Legacy.</description>
</book>
<book id="bk106">
<title>Lover Birds</title>
<publish_date>2000-09-02</publish_date>
<description>When Carla meets Paul at an ornithology conference,
tempers fly as feathers get ruffled.</description>
</book>
<book id="bk107">
<title>Splish Splash</title>
<publish_date>2000-11-02</publish_date>
<description>A deep sea diver finds true love twenty thousand
leagues beneath the sea.</description>
</book>
<book id="bk108">
<title>Creepy Crawlies</title>
<publish_date>2000-12-06</publish_date>
<description>An anthology of horror stories about roaches, centipedes,
LDRP-ITR
35
Web Data Management (IT701-N) 20BEIT30041

scorpions and other insects.</description>


</book>
<book id="bk109">
<title>Paradox Lost</title>
<publish_date>2000-11-02</publish_date>
<description>After an inadvertant trip through a Heisenberg
Uncertainty Device, James Salway discovers the problems of being
quantum.</description>
</book>
<book id="bk110">
<title>Microsoft .NET: The Programming Bible</title>
<publish_date>2000-12-09</publish_date>
<description>Microsoft's .NET initiative is explored in detail in this deep
programmer's reference.</description>
</book>
<book id="bk111">
<title>MSXML3: A Comprehensive Guide</title>
<publish_date>2000-12-01</publish_date>
<description>The Microsoft MSXML3 parser is covered in
detail, with attention to XML DOM interfaces, XSLT processing, SAX
and more.</description>
</book>
<book id="bk112">
<title>Visual Studio 7: A Comprehensive Guide</title>
<publish_date>2001-04-16</publish_date>
<description>Microsoft Visual Studio 7 is explored in depth, looking at
how Visual Basic, Visual C++, C#, and ASP+ are integrated into a
comprehensive development environment.</description>
</book>
</catalog>

Join Query:
<catalog>{ f

LDRP-ITR
36
Web Data Management (IT701-N) 20BEIT30041

or
$i in doc('./books.xml')/catalog/book,
$c in doc('./books_info.xml')/catalog/book

where
$i/title = $c/title and
$i/price >= 30
order by
$i/title
return
<book>
<title>{ $i/title }</title>
<publish_date>{ $c/publish_date }</publish_date>
<price>{ $i/price }</price>
</book>

}
</catalog>

Output:
<catalog>
<book>
<title>XML Developer's Guide</title>
<publish_date>2000-10-01</publish_date>
<price>44.95</price>
</book>
<book>
<title>Microsoft .NET: The Programming Bible</title>
<publish_date>2000-12-09</publish_date>
<price>36.95</price>
</book>
<book>
<title>MSXML3: A Comprehensive Guide</title>
LDRP-ITR
37
Web Data Management (IT701-N) 20BEIT30041

<publish_date>2000-12-01</publish_date>
<price>36.95</price>
</book>
<book>
<title>Visual Studio 7: A Comprehensive Guide</title>
<publish_date>2001-04-16</publish_date>
<price>49.95</price>
</book>
</catalog>

Group Query:
<catalog>{
for $g in doc('./books.xml')/catalog/book group by
$g/genre
return <books genre={$g/genre} count={count($g/genre)} />
}
</catalog>
Output:
<catalog>
<book genre="Computer" count="4" />
<book genre="Fantasy" count="4" />
<book genre="Romance" count="2" />
<book genre="Horror" count="1" />
<book genre="Science Fiction" count="1" />
</catalog>

LDRP-ITR
38
Web Data Management (IT701-N) 20BEIT30041

Practical-10

Aim: Create a web service.

(1) Java class to define web


service:import
javax.jws.WebService;@WebService

publicclassHelloWebService{
publicStringsayHello(Stringname){
return"Hello," +name+“!”;
}
}

(2)Java class to publish web service:


importjavax.xml.ws.Endpoint;pu
blicclassWebServicePublisher{
public static void main(String[] args)
{Stringurl="http://localhost:8080/hello";
Endpoint.publish(url, new
HelloWebService());System.out.println("Webser
vicepublished at"+url);
}
}

LDRP-ITR
39
Web Data Management (IT701-N) 20BEIT30041

LDRP-ITR
40

You might also like