HomeDigital EditionSys-Con RadioSearch Web Services Cd
B2B Beginning WS Business Process Management Case Studies Content Management Distributing Computing e-Business Electronic Data Interchange Enterprise Industry Insight Integration Interviews Java & Web Services .NET Portal Product Reviews Scalability & Performance Security SOAP Source Code UDDI Wireless WS Standards WS Tips & Techniques WSDL WS Editorials XML

XQuery: Reporting XML Data by Seshu Kumar Adiraju & Srinivas Thonse
WSJ Vol 04 Issue 11 - pg.50



Listing 1

<?xml version="1.0"?>
<catalogue>
   <book>
	  <title>Hamlet</title>
      <author>Shakespeare</author>
	  <price format="Paperback">4.99</price>
   </book>
   <book>
	  <title>Romeo And Juliet</title>
      <author>Shakespeare</author>
	  <price format="Hardcover">11.89</price>
   </book>
   <book>
	  <title>Time Machine</title>
      <author>H G Wells</author>
	  <price format="Paperback">3.99</price>
   </book>
   <book>
	  <title>King Richard II</title>
      <author>Shakespeare</author>
	  <price format="Paperback">13.99</price>
   </book>
   <book>
	  <title>Midsummer Night's dream</title>
      <author>Shakespeare</author>
	  <price format="Hardcover">12.59</price>
   </book>
   <book>
	  <title>Merchant Of Venice</title>
      <author>Shakespeare</author>
	  <price format="Hardcover">12.60</price>
   </book>
   <book>
	  <title>Julius Ceaser</title>
      <author>Shakespeare</author>
	  <price format="Paperback">4.99</price>
   </book>
</catalogue>

Listing 2

<html>
<body>
<h1 align="center">Book Catalogue</h1>
<table   width="80%"  border="2" columns="2">
	<tr>
		<th> <b>Title</b> </th>
		<th> <b>Author</b> </th>
	</tr>
	{
		let $catalogue := document("catalogue.xml")
		for $book in $catalogue/book
		return
		<tr>
			<td> {string($book/@title) } </td>
			<td> { string($book/@author) } </td>
		</tr>
	}
</table>
</body>
</html>

Listing 3

<html>
<body>
<h1 align="center">Book Catalogue - Paperback</h1>
<table   width="80%"  border="2" columns="3">
	<tr>
		<th> <b>Title</b> </th>
		<th> <b>Author</b> </th>
		<th> <b>Price</b> </th>
	</tr>
	{
		let $catalogue := document("catalogue.xml")
		for $book in $catalogue/book
		where $book/price/@format = "Paperback"
		return
		<tr>
			<td> { string($book/@title)  } </td>
			<td> { string($book/@author) } </td>
			<td> { string($book/price)   } </td>
		</tr>
	}
</table>
</body>
</html>