<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" encoding="utf-8" indent="yes"/>
       <xsl:template match="/people">
   <lidi>
Reach:
       <xsl:for-each select="person[@salary > 20000]">
           <xsl:value-of select="text()"/>
           <xsl:if test="following-sibling::person[@salary > 20000]">
              <xsl:text>, </xsl:text>
           </xsl:if>
       </xsl:for-each>
       Lidi s ID:
       <xsl:apply-templates select="person"/> 
   </lidi>
</xsl:template>
   
<xsl:template name="print_osoba">
   Osoba: <xsl:copy-of select="text()"/>
</xsl:template>
  
<xsl:template match="person" priority="1">
   Bez ID nebo jmena: <xsl:call-template name="print_osoba"/>

</xsl:template>
  
<xsl:template match="person[@id and text()]"  priority="100">
   <osoba uco="{@id}"> 
      <xsl:copy-of select="@salary"/>
      <xsl:call-template name="print_osoba"/>
      <xsl:choose>
      <xsl:when test="@salary > 10000">
         has salary more than 10000
      </xsl:when> 
      <xsl:when test="@salary &lt; 10000 and @salary > 5000">
         has salary between 5000 and 10000
      </xsl:when> 
 
      </xsl:choose>
      <xsl:if test="@house">
         <xsl:variable name="houseid" select="@house"/>
         <xsl:value-of select="//house[@id=$houseid]/text()"/>
      </xsl:if>
   </osoba>
</xsl:template>
      
</xsl:stylesheet>