(Q11) List the publishers who have published more than 100 books.
<big_publishers>
FOR $p IN distinct(document("bib.xml")//publisher)
LET $b := document("bib.xml")/book[publisher = $p]
WHERE count($b) > 100
RETURN $p
</big_publishers>
XSLT equivalent to (Q11)
<big_publishers xsl:version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:for-each select="document('bib.xml')//publisher[not(.=preceding::publisher)]">
<xsl:variable name="b" select="document('bib.xml')/book[publisher=current()]"/>
<xsl:if test="count($b) > 100">
<xsl:copy-of select="."/>
</xsl:if>
</xsl:for-each>
</big_publishers>
- I use the "simplified stylesheet" syntax here and wherever possible in this presentation in order to
- highlight the similarities with XQuery
- make explicit the fact that template rules ("push") are not being used
|