(Q21) Prepare a table of contents for the document "cookbook.xml", containing nested sections and their titles.
LET $b := document("cookbook.xml")
RETURN
<toc>
filter($b, $b//section | $b//section/title | $b//section/title/text() )
</toc>
- This query introduces the
filter() function, which provides very similar functionality to a subset of XSLT template rules.
- Essentially, it filters out all descendant nodes of those in the first set that aren't in the second, resulting in a tree
that consists of a shallow copy of each remaining node preserved in its original hierarchy with respect to the other remaining
nodes.
|