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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XSLT help - variables in template calls

Status
Not open for further replies.

stevecrozz

IS-IT--Management
Jul 4, 2005
20
US
I'm using EXSLT date:day-in-week function here, but the question is very general. Here I have a short template, and in the middle of it I declare a variable "dayOfTheWeek", and also call the template to parse that date into a number representing the day of the week. The value of the variable is "2006-07-19" as you can see from the output. And if I place that value directly into the external template call

(like this)
<xsl:call-template name="date:day-in-week">
<xsl:with-param name="date-time" select="'2006-07-24'" />
</xsl:call-template>

I get the number 2 returned representing Monday. But the following code returns NaN (not a number). Any idea why the value of my variable is not getting passed to the external template the same way as when I just type it in like above?

Code:
<xsl:template name="date-time">
		<xsl:for-each select="time-layout">
			<xsl:if test="layout-key = 'k-p24h-n8-1'">
				<xsl:for-each select="start-valid-time">
					<xsl:variable name="dayOfTheWeek">
						<xsl:value-of select="substring(.,1,10)"/>
					</xsl:variable>
				<text stuff="{$dayOfTheWeek}"></text>
				<xsl:call-template name="date:day-in-week">
   					<xsl:with-param name="date-time" select="'{$dayOfTheWeek}'" />
				</xsl:call-template>
				</xsl:for-each>
			</xsl:if>
		</xsl:for-each>
</xsl:template>

Output::
Code:
<text stuff="2006-07-19"></text>NaN
<text stuff="2006-07-20"></text>NaN
<text stuff="2006-07-21"></text>NaN
<text stuff="2006-07-22"></text>NaN
<text stuff="2006-07-23"></text>NaN
 
And I'm answering my own question, I have a habbit of this. Anyway, the appropraite syntax for putting a variable into <xsl:with-param select=""> is

<xsl:with-param name="date-time" select="$dayOfTheWeek" />

and not

<xsl:with-param name="date-time" select="'{$dayOfTheWeek}'" />
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top