xsl-list
[Top] [All Lists]

RE: selecting elements only if they all have a particular attribute greater than zero

2004-04-14 01:12:16
Hi,

<xsl:key name="roomTypeId" match="//date/roomType"
use="@id"/>

The match pattern can be just "roomType".

<xsl:template match="/property">
<table>
<tr><td><xsl:value-of select="@name"/></td></tr>
</table>
<table width="300" border="0" cellspacing="0"
cellpadding="2">
      <tr>
              <td width="22">&#160;</td>
              <td>roomType</td>
              <td>cost</td>
    </tr>
      
      <xsl:apply-templates
select="//date/roomType[count(.|key('roomTypeId',@id)[1])=1
and @count &gt; 0]"/>

(Because of personal preference, I rewrote the expression to use generate-id.)

  <xsl:apply-templates select="vacancy/month/date/roomType[generate-id() = 
generate-id(key('roomTypeId',@id)) and not(key('roomTypeId',@id)/@count &lt;= 
0)]"/>

Cheers,

Jarno


<Prev in Thread] Current Thread [Next in Thread>