Nested queries in (X)html document
Issues related to W3C XQuery.
-
- Posts: 1
- Joined: Tue Feb 23, 2016 7:29 am
Nested queries in (X)html document
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
-
- Posts: 2879
- Joined: Tue May 17, 2005 4:01 pm
Re: Nested queries in (X)html document
Hi,
So what does the XML structure look like?
You need to nest the second query within the return of the first, for this you need a single element that surrounds everything. Maybe use a div
e.g.
My guess is you'll also need to filter the PERSONA elements depending on the PLAY/TITLE (characters for each play), but this depends on the XML structure.
Regards,
Adrian
So what does the XML structure look like?
You need to nest the second query within the return of the first, for this you need a single element that surrounds everything. Maybe use a div
e.g.
Code: Select all
for $name in $docs/PLAY/TITLE
return
<div>
<h3><a href="#{generate-id($name)}">{data($name)}</a></h3>
<h3>Characters</h3>
<ul>
{
for $character in $docs//PERSONA
return
(<li>{data($character)}</li>)
}
</ul>
</div>
Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service