(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
    1. highlight the similarities with XQuery
    2. make explicit the fact that template rules ("push") are not being used
<<<  1 2 3 4 5 6 7 8 9 10 11 12 13 14 15    >>>