<xsl:for-each select="author/@affiliation"> 3 of these
<xsl:variable name="aff" select="."/>
<xsl:if
test="count(parent::author/preceding-sibling::author[@affiliation = $aff]) = 0">
<affiliation>
<xsl:attribute name="name" ><xsl:value-of select="."/></xsl:attribute>
<xsl:copy-of select="parent::author" /> outputs first
<xsl:copy-of and the rest
select="parent::author/following-sibling::author[$aff = @affiliation]" />
</affiliation>
</xsl:if>
</xsl:for-each>
- This is similar to the XSLT 2.0 approach
- Probably less efficient
- The if test means the search is only over the first of each affiliation
- This item is copied and all the others with the same affiliation