IBM Version 5 Universal Remote User Manual


 
44 The XML Files: Development of XML/XSL Applications Using WebSphere Studio
other holdings, include the author:
FOR $h IN //holding
RETURN
<holding>
$h/title,
IF $h/@type = "Journal"
THEN $h/editor
ELSE $h/author
</holding> SORTBY (title)
Quantifiers
Sometimes we have to test if elements exist that must satisfy a condition.
Find titles of books in which both sailing and windsurfing are mentioned in the
same paragraph:
FOR $b IN //book
WHERE SOME $p IN $b//para SATISFIES
contains($p, "sailing")
AND contains($p, "windsurfing")
RETURN $b/title
Eg 12. Find titles of books in which sailing is mentioned in every
paragraph.
FOR $b IN //book
WHERE EVERY $p IN $b//para SATISFIES
contains($p, "sailing")
RETURN $b/title
Filtering
This filter function takes two operands, each of which is an expression that
evaluates to a ordered set of notes, and returns copies of some of the nodes in
the first operand, while preserving their hierarchic and sequential relationships.
The second operand is the
filter that trims the hierarchical tree. Both operands
must have the same node, not only two nodes of the same value. If the two
operands do have a common root, the result of the filter function is an empty list.
The following example illustrates this process by computing a table of contents
for a document, which contains many levels of nested sections. The query filters
the document and retaining only section elements, title elements nested directly
inside section elements, and the text of those title elements. Other elements,
such as paragraphs and figure titles, are eliminated, leaving only the
skeleton of
the document.
The first argument of filter is the root of a document, and the second argument is
a path expression that identifies the nodes to be preserved from the original
document.