Subject: Re: Number of node in list from stylesheet From: Jeni Tennison <Jeni.Tennison@xxxxxxxxxxxxxxxx> Date: Tue, 23 May 2000 15:19:39 +0100 |
Sebastian, >why pass the monthname as parameter, as opposed to > >select="document('')//foo:month[@name=$monthName] " mode="getNumber" > >? doesnt that the work the same way, and look more natural? You're quite right that that would work if the $monthName was defined as a top-level variable, and is more elegant. I didn't make clear that I was assuming the $monthName variable was defined within a template rather than at a top level, and thus inaccessible to other templates aside from by passing it through as a parameter. This is necessary in Cheun's case because each product defines a best-before date, each of which has to be converted into a number to be compared with today's date. Actually, in the real case $monthName isn't even defined except within the parameter. Here's the full template: <xsl:template match="STUFF/*"> <xsl:param name="today" /> <xsl:variable name="bbString" select="BESTBEFORE" /> <xsl:variable name="bbDay" select="format-number(number(substring-before(BESTBEFORE, ' ')), '00')" /> <xsl:variable name="bbMonth"> <xsl:apply-templates select="document('')//foo:month" mode="getNumber"> <xsl:with-param name="monthName" select="substring-before(substring-after($bbString, ' '), ' ')" /> </xsl:apply-templates> </xsl:variable> <xsl:variable name="bbYear" select="substring-after(substring-after(BESTBEFORE, ' '), ' ')" /> <xsl:variable name="bb" select="number(concat($bbYear, $bbMonth, $bbDay))" /> <xsl:element name="{name()}"> <xsl:copy-of select="BESTBEFORE" /> <CONDITION> <xsl:choose> <xsl:when test="$today > $bb"> <xsl:text>expired</xsl:text> </xsl:when> <xsl:otherwise> <xsl:value-of select="CONDITION" /> </xsl:otherwise> </xsl:choose> </CONDITION> </xsl:element> </xsl:template> Thanks, Jeni Dr Jeni Tennison Epistemics Ltd, Strelley Hall, Nottingham, NG8 6PE Telephone 0115 9061301 ? Fax 0115 9061304 ? Email jeni.tennison@xxxxxxxxxxxxxxxx XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: Number of node in list from sty, Sebastian Rahtz | Thread | Re: Number of node in list from sty, Juergen Hermann |
Re: XSLT & XBase ( Dans Special the, Eric van der Vlist | Date | Re: template conflicts, Jeni Tennison |
Month |