server-php-xml-class-xquery-lite-demo.php / php
<? session_start(); set_magic_quotes_runtime (0); example["query"]=Array( '<bib> { for bib)/bib/book where b/@year > 1991 return <book year="{ b/title } </book> } </bib> ', '<results> { for bib)/bib/book,b/title,b/author return <result> { a } </result> } </results>', '<results> { for bib)/bib/book return <result> { b/author } </result> } </results> ', '<results> { for bib)//author) return <result> {b in xmlmem(a2 in a2=b/title} } </result> } </results>', '<books-with-prices> { for bib)//book, reviews)//entry where a/title return <book-with-prices> { <price-amazon>{ a/price/text() }</price-amazon> <price-bn>{ </price-bn> </book-with-prices> } </books-with-prices>', '<bib> { for b in xmlmem(//book where count(b/author) > 2 return <book> { a in a} } <et-al /> </book> } { for bib)//book where count(<book> { b/title } { for b/author[position()<=2] return {</book> } </bib>', '', '', '<results> { for t in xmlmem(//title[contains(./text(),"XML")] return {t} } </results> ', '', '<bib> { for bib)//book[author] return <book> { b/author } </book> } { for bib)//book[editor] return <reference> { b/editor/affiliation} </reference> } </bib> ',''); _SESSION["bib"])) { <bib> <book year="1994"> <title>TCP/IP Illustrated</title> <author><last>Stevens</last><first>W.</first></author> <publisher>Addison-Wesley</publisher> <price> 65.95</price> </book> <book year="1992"> <title>Advanced XML Programming in the Unix environment</title> <author><last>Stevens</last><first>W.</first></author> <publisher>Addison-Wesley</publisher> <price>65.95</price> </book> <book year="2000"> <title>Data on the Web</title> <author><last>Abiteboul</last><first>Serge</first></author> <author><last>Buneman</last><first>Peter</first></author> <author><last>Suciu</last><first>Dan</first></author> <publisher>Morgan Kaufmann Publishers</publisher> <price> 39.95</price> </book> <book year="1999"> <title>The Economics of Technology and Content for Digital TV</title> <editor> <last>Gerbarg</last><first>Darcy</first> <affiliation>CITI</affiliation> </editor> <publisher>Kluwer Academic Publishers</publisher> <price>129.95</price> </book> </bib>'; session_register("bib"); } if(!isset(_SESSION["reviews"])) { <reviews> <entry> <title>Data on the Web</title> <price>34.95</price> <review> A very good discussion of semi-structured database systems and XML. </review> </entry> <entry> <title>Advanced Programming in the Unix environment</title> <price>65.95</price> <review> A clear and detailed discussion of UNIX programming. </review> </entry> <entry> <title>TCP/IP Illustrated</title> <price>65.95</price> <review> One of the best books on TCP/IP. </review> </entry> </reviews>'; session_register("reviews"); } if(isset(_REQUEST["set"])) { _REQUEST["varname"]; // We process an update here varname}=stripslashes(varname"); } if(isset(bib); unset(<html> <head> <title>Xquery Lite demo(PHP)</title> <link rel="stylesheet" href="main.css" type="text/css"> </head> <body> <div align="center"> <table border="0" width="80%"> <tr> <td bgcolor="#aaaaee" class="textblbl" align="center">Xquery Lite demo</td> </tr> </table> <br /> <table border="0" width="80%"> <tr> <td bgcolor="#eeeeff" class="text">This demo explains how to solve the W3C "XMP" use cases using <a href="http://phpxmlclasses.sourceforge.net/xquery_lite.html">Xquery Lite 1.0.</a> The PHP implementation of Xquery Lite is used to show how the queries are evaluated and you can test your own queries too. </td> </tr> </table> <br /> <table border="0" width="80%"> <tr> <td bgcolor="#eeeeff" class="text">This is a list of the XML xmlmems used in the demo, xmlmems can be edited (under your own risk). If you mess things up click here to <a href="?recover=1">Recover the original examples</a> <ul> <li><a href="?edit=bib">bib.xml</a>: an xml xmlmem listing books <li><a href="?edit=reviews">reviews.xml</a>: an xml xmlmem with book reviews </ul> </td> </tr> </table> <?if(isset(edit)) { ?> <form method="post" action="<?=<textarea name='value' rows='20' cols='80'>{</textarea><br/>"); ?> <input type="hidden" name="varname" value="<?=edit?>" /> <input type="submit" name="set" value="update" /> <input type="submit" name="cancel" value="cancel" /> </form> <? } ?> <? if(isset(query=stripslashes(xq=new XqueryLite(); xq->evaluate_xqueryl(_REQUEST["examplenum"])) { example["query"][enum"]]; text=_REQUEST["examplenum"]]; } ?> <br/> <table border="0" width="80%"> <tr> <td bgcolor="#eeeeff" class="text">This is a list of the queries that are prepared to be run over the sample xmlmems, you can try your own queries if you want <br/> <a href="?examplenum=0">Use-case 1</a>, <a href="?examplenum=1">Use-case 2</a>, <a href="?examplenum=2">Use-case 3</a>, <a href="?examplenum=3">Use-case 4</a>, <a href="?examplenum=4">Use-case 5</a>, <a href="?examplenum=5">Use-case 6</a>, <a href="?examplenum=6">Use-case 7</a>, <a href="?examplenum=7">Use-case 8</a>, <a href="?examplenum=8">Use-case 9</a>, <a href="?examplenum=9">Use-case 10</a>, <a href="?examplenum=10">Use-case 11</a>, <a href="?examplenum=11">Use-case 12</a>, </td> </tr> </table> <br/> <?if(isset(<table border="0" bgcolor="ddddff" width="80%"> <tr> <td align="center" valign="top" class="text" width="50%"> <? print("<p>Query: <i>text</i></p>"); ?> </td> </tr> </table> <? } ?> <form method="post" action="<?=<table border="0" width="80%" cellpadding="0" cellspacing="0"> <tr> <td align="center" bgcolor="#ccccff" class="textbl">Query</td> <td align="center" bgcolor="#ddddff" class="textbl">Result</td> </tr> <tr> <td align="center" bgcolor="#ccccff" class="text"> <textarea name="query" rows="20" cols="40"><?if(isset(query)) {print(</textarea></td> <td align="center" bgcolor="#ddddff" class="text"><textarea name="result" rows="20" cols="40"><?if(isset(result)){print(</textarea></td> </tr> <tr> <td align="center" bgcolor="#aaaaff" class="text" colspan="2"><input type="submit" name="execute" value="execute" /></td> </tr> </table> <input type="hidden" name="text" value="<?=text?>" /> </form> </body> </html>
(C) Æliens 20/2/2008
You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.