[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: selecting elements only if they all have a partic

Subject: RE: 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)
elements what are they
Hi,

Thank you for the reply, that solved my problem.
If I&#12288;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 &gt;= $checkIn) and
(key('roomTypeId',@id)/../@date &lt;=  $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:  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 &gt; 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 
=
&lt;=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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.