But how much is left for PHP to do?

<?php
$mgr = new XmlManager(null);
$con = $mgr->openContainer("website.dbxml");
$results = $mgr->query("
    declare namespace atom='http://www.w3.org/2005/Atom';
    declare namespace html='http://www.w3.org/1999/xhtml';
<html xmlns='http://www.w3.org/1999/xhtml'>
<head>
<title>Mokka mit Schlag</title>
</head>
<body>
    <h1> { 
     string(doc('website.dbxml/pages')/atom:feed/atom:title) 
    } </h1>
    { for $entry in doc('website.dbxml/pages')//atom:entry
    return
      <div xmlns='http://www.w3.org/1999/xhtml'>
      <h2> { string($entry/atom:title) } </h2>
      { $entry/atom:content/html:div } 
      </div>
     }
<p>
Of course as usual, you can put other HTML markup
and PHP scripts in the document where you like.
However since this is exactly what XQuery databases are
optimized for and XQuery is designed for, I tend to 
prefer to do as much of my heavy lifting in XQuery as possible.
</p>

<p>
Generally speaking, you can get a lot more web work done in a native 
XML database than in a SQL database because XQuery is designed to
generate complete documents, while SQL is designed only to produce tables
that then need to be further massaged into document form for
human consumption. 
</p>

</body>
</html>
");

// XQueries return sequences so you have to 
// iterate through them to get all the results
$results->reset();
while($results->hasNext()) 
{
    $val = $results->next();
    print $val->asString();
}
 
?>


Previous | Next | Top | Cafe con Leche | Cafe au Lait

Copyright 2002-2007 Elliotte Rusty Harold
elharo@metalab.unc.edu
Last Modified October 23, 2007