Click to See Complete Forum and Search --> : Hi! XSQL/XSL Question How to do math? (Between 2 variables)


964
02-29-2004, 08:47 AM
Hi!


I have a XSQL page which gets several parameters in form an other page.. this is bit big (for me) / complex thing to explain fully but here the main points.

Where do I need this? A school assignment to be returned. It is supposed to be an airport web page, where you can book flights. IN this question I ask for help to calculate the REMAINING empty seats on a flight that a customer has selected.


I have an *.xsql page which does 4 different Queries to an Oracle database. Here 2 of those, which are concerned in this "dilemma/question":

<xsql:query rowset-element="RESERVATIONS" row-element="RESERVEDSEATS">
select count(TICKET.OUTBOUND) RESERVED
from TICKET
where TICKET.OUTBOUND='{@LENNONNRO}'
</xsql:query>

<xsql:query rowset-element="SEATS" row-element="PLANECAPACITY">
select CAPACITY
from AIRCRAFT
where SERIAL_NUMBER='{@LENTOKONENRO}'
</xsql:query>


On the base of the results I get the contents of those queries to a *.xsl page where I refer to each value like this:

<xsl:for-each select="//RESERVEDSEATS">
<xsl:variable name="TAKENSEATS">
<xsl:value-of select="RESERVED"/>
</xsl:variable>
</xsl:for-each>

<xsl:for-each select="//PLANECAPACITY">
<xsl:variable name="ALLSEATS">
<xsl:value-of select="CAPACITY"/>
</xsl:variable>
</xsl:for-each>

(THose up there work 100% and are ok, so no problem with them. Those variables do get a value (ALLSEATS and TAKENSEATS))

What I should do is to get the value of "RESERVED" diminished from the "CAPACITY" and to be able to print it out where ever I want on the *.XSL page :]

BUT HOW on earth can that Math be done? I have no clue, no material to find the info (this is a school task)
Like this: ?

Step 1. Create a variable that contains the EARLIER created variables beeing diminished from each other.

<xsl:variable name="FREESEATS">{$ALLSEATS}-{$TAKENSEATS}</xsl:variable><br/><br/>

Step 2. Print it out to be visible in a table cell (IF there is space left):

<td> Dear <xsl:value-of select="USERNAME"/> there are '{$FREESEATS}' on the flight you requested. </td>



One more dilemma. How do I print an variable (the value of a variable into text. Just with the good old <xsl:value-of select="variablename"/>?




Yes I tried PL-SQL earlier to do this with it, but see the problem was that I was not able to create a *.xsql method/ reference-cursor-function -sentence that had worked properly. :/

But please some one, help me with this one asp, cause I deffinately Am in a hurry....

964
02-29-2004, 09:18 AM
Ha!! I did IT! :) :)


Here:

<td> There
<xsl:for-each select="//RESERVEDSEATS">
<xsl:variable name="TAKENSEATS">
<xsl:value-of select="RESERVED"/>
</xsl:variable> are <xsl:value-of select="RESERVED"/>
seats reserved from this flight so there are
<xsl:for-each select="//PLANECAPACITY">
<xsl:variable name="ALLSEATS">
<xsl:value-of select="CAPACITY"/>
</xsl:variable>
<xsl:value-of select="CAPACITY"/>

<xsl:variable name="FREESEATS" select="($ALLSEATS - $TAKENSEATS)">
</xsl:variable>
<form action="lippu6.xsql?nimi={$FREESEATS}" method="post"/>
<br/><br/>
</xsl:for-each>
</xsl:for-each>
</td>
NOw how on earth could I get it printend among the text, well meaby It can be sorted out.. :) Thanks for replying slowly, I discovered the answer with luck and thinking (and an anonyme search engine helped me too).

964
02-29-2004, 09:22 AM
Oh and to print a variable into plain text use :

<xsl:value-of select="$FREESEATS"/>

I know I am nearly flooding this forum ;) But See I thought that IF some one else is as rookie/green with these Issues, then he/she might have some use for this information. *Cheers*