Nested queries in (X)html document
Posted: Wed Feb 24, 2016 12:26 am
I've build the following xquery document.
It works but not quite the way I expected it. I'm trying to insert the section beginning with <h3>Characters</h3> and the associated query inside the first query but when I put it inside I get an error: Left operand of '>' needs parenthesis.
I have not been able to find good documentation as to how to nest queries. Is this possible?
If I run the document as it is in the version above it works but not as I want it to. It generates a list names for all the plays in the collections and then it builds a complete list of all characters in all plays. Using oXygen 17.1
Code: Select all
xquery version "3.0";
declare variable $docTitle := "Shakespeare Plays";
declare variable $docs :=
collection("file:////Users/carlos/code/xquery/shakspeare?select=*.xml");
<html>
<body>
<!-- Use $docTitle variable -->
<h1>{$docTitle}</h1>
<h2>Plays</h2>
{
for $name in $docs/PLAY/TITLE
return
<h3><a href="#{generate-id($name)}">{data($name)}</a></h3>
(: I woud like to insert the character list for each play here :)
}
<h3>Characters</h3>
<ul>
{
for $character in $docs//PERSONA
return
(<li>{data($character)}</li>)
}
</ul>
</body>
</html>
I have not been able to find good documentation as to how to nest queries. Is this possible?
If I run the document as it is in the version above it works but not as I want it to. It generates a list names for all the plays in the collections and then it builds a complete list of all characters in all plays. Using oXygen 17.1