Database Reference
In-Depth Information
</body>
</html>
When you run this from within eXide nothing too exciting happens, but when you
try it from the browser, you see the result shown in Figure 3-4 .
Figure 3-4. The exciting output of our first basic HTML page
OK, now we're getting somewhere! Now let's use the output from “Listing the Plays
(XML)” on page 45 to display a list of plays (we'll use the code with the collection
function here, but the code that uses the xmldb:get-child-resources function is
also fine). With a little copy and pasting, the code in Example 3-6 is constructed
quickly.
Example 3-6. Code for the HTML page that returns a list of plays (plays-home.xq)
xquery version "3.0" ;
declare option exist:serialize "method=xhtml media-type=text/html" ;
declare variable $ page-title := "Our Shakespeare plays" ;
let $ play-info :=
<plays>
{
for $ resource in collection ( '/db/apps/exist101/data' )
return
<play uri = "{ base-uri ( $ resource )}"
name = "{ util:unescape-uri ( replace ( base-uri ( $ resource ),
".+/(.+)$" , "$1" ), "UTF-8" )}" >
{
$ resource / PLAY / TITLE / text ()
}
</play>
}
</plays>
return
<html>
<head>
<meta HTTP-EQUIV = " Content-Type " content = " text/html; charset=UTF-8 " />
<title> { $ page-title } </title>
</head>
<body>
 
Search WWH ::




Custom Search