topical media & game development
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>
{ a/price/text() }</price-amazon>
<price-bn>{ b in xmlmem(b/author) > 2
return
<book>
{ a in a}
}
<et-al />
</book>
}
{
for bib)//book
where count(b/title }
{
for b/author[position()<=2]
return {t in xmlmem(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"])) {
_SESSION["reviews"])) {
_REQUEST["set"])) {
_REQUEST["varname"];
// We process an update here
varname}=stripslashes(varname");
}
if(isset(bib);
unset(edit)) {
?>
<form method="post" action="<?={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"][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(text</i></p>"); ?>
</td>
</tr>
</table>
<?
}
?>
<form method="post" action="<?=query)) {print(result)){print(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.