<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:saxon="http://saxon.sf.net/" version="2.0"> <xsl:template match="bib"> <xsl:variable name="list" select="for $a in distinct-values(//author) return ($a, //book[author = $a]/title)"/> <xsl:message> <xsl:value-of select="$list" separator=", "/> </xsl:message> </xsl:template> </xsl:stylesheet>