(Q12) Invert the structure of the input document so that, instead of each book element containing a list of authors, each distinct author element contains a list of book-titles.

<author_list>
   FOR $a IN distinct(document("bib.xml")//author)
   RETURN
      <author>
         <name> $a/text() </name>,
         FOR $b IN document("bib.xml")//book[author = $a]
         RETURN $b/title
      </author>
</author_list>

XSLT equivalent to (Q12)

<author_list xsl:version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:for-each select="document('bib.xml')//author[not(.=preceding::author)]">
    <author>
      <name><xsl:value-of select="."/></name>
      <xsl:for-each select="document('bib.xml')//book[author=current()]">
        <xsl:copy-of select="title"/>
      </xsl:for-each>
    </author>
  </xsl:for-each>
</author_list>
<<<  1 2 3 4 5 6 7 8 9 10 11 12 13 14 15    >>>