|
Subject: RE: [xsl] selecting elements only if they all have a particular attribute greater than zero From: Donal Regan <donal_regan10@xxxxxxxxxxx> Date: Tue, 20 Apr 2004 13:11:30 +0100 (BST) |
Hi,
Thank you for the reply, that solved my problem.
If I understand correctly then
<xsl:apply-templates
select="property[@selected='yes']/vacancy/month/date/roomType[generate-id()
= generate-id(key('roomTypeId',@id)) and
not(key('roomTypeId',@id)/@count = 0) and
(key('roomTypeId',@id)/../@date >= $checkIn) and
(key('roomTypeId',@id)/../@date <= $checkOut)]"
mode="vacancies"/>
($checkIn and $checkOut are parameters with values 4
and 6 say)
should only concern itself with the roomTypes between
the dates 4 to 6 inclusive and I should be able to see
the 4 types of room displayed(because their count is
greater than zero for all those days), but what seems
to be happening is that because <roomType id="1"> has
a count of zero for a date beforehand, it is not being
displayed. What am I missing? How do I say "only
select roomTypes between the 4th and 6th that have a
count greater than zero?" rather than "only select
roomTypes that have a count greater than zero and then
select the roomTypes leftover between the 4th and
6th?"
<property name="Hotel A" id="1">
<vacancy>
<month name="4">
<date date="1">
<roomType id="1" count="1" type="1R" cost="100"/>
<roomType id="10" count="1"type="2DK" cost="100"/>
<roomType id="13" count="1" type="3DK" cost="100"/>
</date>
<date date="2">
<roomType id="1" count="0" type="1R" cost="100"/>
<roomType id="10" count="1" type="2DK" cost="100"/>
<roomType id="11" count="1" type="2DK" cost="200"/>
<roomType id="12" count="2" type="2LDK" cost="100"/>
</date>
<date date="3">
<roomType id="1" count="0" type="1R" cost="100"/>
<roomType id="10" count="1" type="2DK" cost="100"/>
<roomType id="11" count="1" type="2DK" cost="200"/>
<roomType id="12" count="2" type="2LDK" cost="100"/>
</date>
<date date="4">
<roomType id="1" count="1" type="1R" cost="100"/>
<roomType id="10" count="1" type="2DK" cost="100"/>
<roomType id="11" count="1" type="2DK" cost="200"/>
<roomType id="12" count="2" type="2LDK" cost="100"/>
</date>
<date date="5">
<roomType id="1" count="1" type="1R" cost="100"/>
<roomType id="10" count="1" type="2DK" cost="100"/>
<roomType id="11" count="1" type="2DK" cost="200"/>
<roomType id="12" count="2" type="2LDK" cost="100"/>
</date>
<date date="6">
<roomType id="1" count="1" type="1R" cost="100"/>
<roomType id="10" count="1" type="2DK" cost="100"/>
<roomType id="11" count="1" type="2DK" cost="200"/>
<roomType id="12" count="2" type="2LDK" cost="100"/>
</date>
</month>
</vacancy>
</property>
Thanks,
Donal
Date: Wed, 14 Apr 2004 11:12:16 +0300
To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
From: <Jarno.Elovirta@xxxxxxxxx>
Subject: RE: [xsl] selecting elements only if they all
have a
particular attribute greater than zero
Message-ID:
<E392EEA75EC5F54AB75229B693B1B6A708288A0E@xxxxxxxxxxxxxxxxxxxxxx>
Hi,
> <xsl:key name=3D"roomTypeId"
match=3D"//date/roomType"
> use=3D"@id"/>
The match pattern can be just "roomType".
> <xsl:template match=3D"/property">
> <table>
> <tr><td><xsl:value-of select=3D"@name"/></td></tr>
> </table>
> <table width=3D"300" border=3D"0" cellspacing=3D"0"
> cellpadding=3D"2">
> <tr>
> <td width=3D"22"> </td>
> <td>roomType</td>
> <td>cost</td>
> </tr>
> =09
> <xsl:apply-templates
>
select=3D"//date/roomType[count(.|key('roomTypeId',@id)[1])=3D1
> and @count > 0]"/>
(Because of personal preference, I rewrote the
expression to use =
generate-id.)
<xsl:apply-templates =
select=3D"vacancy/month/date/roomType[generate-id()
=3D =
generate-id(key('roomTypeId',@id)) and
not(key('roomTypeId',@id)/@count
=
<=3D 0)]"/>
Cheers,
Jarno
____________________________________________________________
Yahoo! Messenger - Communicate instantly..."Ping"
your friends today! Download Messenger Now
http://uk.messenger.yahoo.com/download/index.html
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| Re: [xsl] typing of integer operati, David Carlisle | Thread | [xsl] Re: Xalan Uses which Parser, Joseph Kesselman |
| Re: [xsl] typing of integer operati, David Carlisle | Date | RE: [xsl] Parameters in localized m, Jeroen Hellingman |
| Month |