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

Subject: RE: [xsl] selecting elements only if they all have a particular attribute greater than zero
From: <Jarno.Elovirta@xxxxxxxxx>
Date: Wed, 14 Apr 2004 11:12:16 +0300
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

Current Thread