Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

xsl:if for position() + x

Status
Not open for further replies.

Sarky78

Programmer
Oct 19, 2000
878
GB
Hi,

I've been trying to prove a concept now for what seems like an age. With the help of people on this forum I've managed to get the seating plan output on the screen as I'd like, but now I need to display X number of seats that are available next to each other. So if the user wants to book four seats next to each other on a row, i want to only output available seats that are in a group of four. explaining this badly i know.

I think i've managed to achieve what i want by hardcoding if statements, but I need to be able to use a param that will be passed in.

this is the if statement that i have at the moment
Code:
<xsl:when test="((./seat_status[(position()+1)]=0))">

what i really need to be able to do is, something like "are there x number of seats available from this point on the row?"

I really can't think of anyway of doing this in xslt.

Any ideas?

TIA

Tony
 
First of all I thought you'd need to use recursion, but having a think about it, maybe you can use the sum function? If seat status is 0 that means available? So why not sum the next x seats to see if total = 0? Something along the lines of:
Code:
<xsl:when test="sum(./seat_status[position() &gt; 1][position() &lt;= $x]) = 0"/>
You might have to alter this, cos I don't know what the context node is or the structure of the xml

Jon

"I don't regret this, but I both rue and lament it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top