[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] Q - Value of param doesn't change !


Subject: Re: [xsl] Q - Value of param doesn't change !
From: Ahsan Ali <doubleletter@xxxxxxxxx>
Date: Tue, 31 May 2005 16:59:30 +0400

David,

Thanks for the reply..  I'm sorry if my explanation was not clear..
Here's my schedule.xsl (with the irrelevant parts removed):
--------------- schedule.xsl
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:a="http://tempuri.org/GemWebServices/Services"
exclude-result-prefixes="a diffgr soap"
xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1"
                xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xs="http://www.w3.org/2001/XMLSchema">

	<xsl:output method="html" indent="yes"/>

	<xsl:template match="/">

		<table width="98%" border="0" cellPadding="0" cellSpacing="1"
bgcolor="#CCCCCC" class="searchResult">
			<tbody>
				<xsl:apply-templates
select="soap:Envelope/soap:Body/a:FlightSchedulesResponse/a:FlightSchedulesRe
sult/diffgr:diffgram/AirAvail/ReturnAvailFlt"/>
			</tbody>
		</table>
	</xsl:template>

	<!---> This needs work. //-->
	<xsl:template name="Jrny">
		<xsl:param name="hrs"/>
		<xsl:param name="mins"/>
		<xsl:value-of select="concat($hrs, ' hrs ', $mins, ' mins')"/>
	</xsl:template>

	<xsl:template
match="soap:Envelope/soap:Body/a:FlightSchedulesResponse/a:FlightSchedulesRes
ult/diffgr:diffgram/AirAvail/ReturnAvailFlt">
		<tr>
			<td>
				<xsl:call-template name="Jrny">
					<xsl:with-param name="hrs" select="number(format-number(JrnyTm
div 60, '#'))"/>
					<xsl:with-param name="mins" select="JrnyTm -
(number(format-number(JrnyTm div 60, '#')) * 60)"/>
				</xsl:call-template>
			</td>
		</tr>
	</xsl:template>
</xsl:stylesheet>
---------------

And here's a minimal XML sample...

--------------- minimal.xml
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
	<soap:Body>
		<FlightSchedulesResponse
xmlns="http://tempuri.org/GemWebServices/Services">
			<FlightSchedulesResult>
				<diffgr:diffgram
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"
xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1">
					<AirAvail xmlns="">
						<ReturnAvailFlt diffgr:id="ReturnAvailFlt1" msdata:rowOrder="0">
							<AirV>AF</AirV>
							<FltNum>526</FltNum>
							<OpSuf/>
							<StartDt>20051105</StartDt>
							<StartAirp>CDG</StartAirp>
							<EndAirp>DXB</EndAirp>
							<StartTm>1315</StartTm>
							<EndTm>2255</EndTm>
							<DayChg>00</DayChg>
							<Conx>N</Conx>
							<AirpChg/>
							<Equip>332</Equip>
							<Spare1/>
							<NumStops>0</NumStops>
							<OpAirVInd>N</OpAirVInd>
							<Perf/>
							<LinkSellAgrmnt>SS</LinkSellAgrmnt>
							<DispOption>Y</DispOption>
							<InsideAvailOption>Y</InsideAvailOption>
							<GenTrafRestriction/>
							<DaysOperates>YYYYYYY</DaysOperates>
							<JrnyTm>400</JrnyTm>
							<EndDt>20051205</EndDt>
							<OpAirV/>
							<OpFltDesignator/>
							<OpFltSuf/>
							<StartTerminal>2F</StartTerminal>
							<EndTerminal>1</EndTerminal>
							<FltTm>435</FltTm>
							<LSAInd>N</LSAInd>
							<GalileoAirVInd>Y</GalileoAirVInd>
						</ReturnAvailFlt>
						<ReturnAvailFlt diffgr:id="ReturnAvailFlt2" msdata:rowOrder="1">
							<AirV>EK</AirV>
							<FltNum>74</FltNum>
							<OpSuf/>
							<StartDt>20051105</StartDt>
							<StartAirp>CDG</StartAirp>
							<EndAirp>DXB</EndAirp>
							<StartTm>1430</StartTm>
							<EndTm>10</EndTm>
							<DayChg>01</DayChg>
							<Conx>N</Conx>
							<AirpChg/>
							<Equip>772</Equip>
							<Spare1/>
							<NumStops>0</NumStops>
							<OpAirVInd>N</OpAirVInd>
							<Perf/>
							<LinkSellAgrmnt>SS</LinkSellAgrmnt>
							<DispOption>Y</DispOption>
							<InsideAvailOption>Y</InsideAvailOption>
							<GenTrafRestriction/>
							<DaysOperates>YYYYYYY</DaysOperates>
							<JrnyTm>400</JrnyTm>
							<EndDt>20051205</EndDt>
							<OpAirV/>
							<OpFltDesignator/>
							<OpFltSuf/>
							<StartTerminal>1</StartTerminal>
							<EndTerminal>1</EndTerminal>
							<FltTm>400</FltTm>
							<LSAInd>N</LSAInd>
							<GalileoAirVInd>Y</GalileoAirVInd>
						</ReturnAvailFlt>
					</AirAvail>
				</diffgr:diffgram>
			</FlightSchedulesResult>
		</FlightSchedulesResponse>
	</soap:Body>
</soap:Envelope>
---------------

The above gives the output:

for the first ReturnAvailFlt, '7 hrs -15 mins' [this is correct, but I
need it without the hyphen]
for the second Return AvailFlt, '7 hrs -20 mins' [this is wrong, it
should be 7 hrs 40 mins].

Finally, the journey time given in the xml sheet is in minutes.

Thank you,

Regards, Ahsan

On 5/31/05, David Carlisle <davidc@xxxxxxxxx> wrote:
>
>   The call template code is inside a for-each element. So, ideally, it
>   should change its JrnyTm value everytime, right ? Well..it looks like
>   once the xsl:param [hrs] is set to 7, it stays that ! It looks as if
>   the select expression is not being evaluated for every element..
>
> You don't show anything like enough information for anyone to really
> offer any help, but since JrnyTm is specified as having parameters these
> parameters will be re-evaluated each time the template is called.
>
> However a couple of comments
>
> JrnyTm is a template not a variable so it doesn't
> have a value as such, so I'm not sure what you mean by
> "change its JrnyTm value everytime,"
> also do you have elements called JrnyTm in the source?
>
> elect="JrnyTm - (number(format-number(JrnyTm div 60, '#')) * 60)"/>
> </xsl:call-template>
>
> contains two references to the string value of a child element with name
> JrnyTm, not a reference to anything defined in the stylesheet.
>
>
> David
>
> ________________________________________________________________________
> This e-mail has been scanned for all viruses by Star. The
> service is powered by MessageLabs. For more information on a proactive
> anti-virus service working around the clock, around the globe, visit:
> http://www.star.net.uk
> ________________________________________________________________________


Current Thread
Keywords
xml