<?xml version="1.0" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" indent="yes" />

<xsl:key name="byColor" match="item" use="favouriteColor" />

<xsl:template match="data"> 
   <ul>
     <xsl:for-each select="item[generate-id() = generate-id(key('byColor', favouriteColor)[1])]" >
        <xsl:sort select="favouriteColor " />
        <li> 
             Color: <xsl:value-of select="favouriteColor" /> 
             <ul> 
                      <xsl:for-each select="key('byColor', favouriteColor)" >
                         <li>  
                             <xsl:value-of select="name" /> 
                               <ul>
                                <li> Born: <xsl:value-of select="birthday" />,  <xsl:value-of select="birthPlace" /> </li>  
                                <li> Main interests: <xsl:value-of select="mainInterest" /></li>
                                </ul>
                         </li>
                      </xsl:for-each> 
             </ul>
       </li> 
     </xsl:for-each> 
   </ul> 
</xsl:template>
</xsl:stylesheet>
