Altova Mailing List Archives
>xsl-list Archive Home
>Recent entries
>Thread Prev - Re: [xsl] Creating a html
[Thread Next]
Re: [xsl] Creating a html
To: xsl-list@-----.------------.---
Date: 1/12/2010 9:10:00 PM
The problem is now solved, thanks to you all and some code I found by
googling, which I modified to suit my needs,
For the months, Kens question, "why do you need an algorithmic
approach?" made me realize I didn't. Instead I just made 12 static
<choose> parts, one for each month. Like this:
<xsl:template match="@month">
<xsl:variable name="month">
<xsl:value-of select="."/>
</xsl:variable>
<xsl:choose>
<xsl:when test="$month='januari'">
<option value="januari" selected="selected">
januari
</option>
</xsl:when>
<xsl:otherwise>
<option value="januari">
januari
</option>
</xsl:otherwise>
</xsl:choose>
<!-- and so on -->
</xsl:template>
The solution for the days and years was indeed to use recursive template calls.
The code for this is found below, if anybody happens upon this thread
and is interested in how I solved it.
Best regards,
Martin Jackson
<xsl:template match="@day">
<xsl:variable name="day">
<xsl:value-of select="."/>
</xsl:variable>
<xsl:call-template name="incrementValue">
<xsl:with-param name="value">1</xsl:with-param>
<xsl:with-param name="invar" select="$day"></xsl:with-param>
<xsl:with-param name="stop">31</xsl:with-param>
</xsl:call-template>
</xsl:template>
<!-- and another template just like it for the years, but with the
parameters "value" and "stop" changed from 1 and 31 to 1900 and 2010.
Plus this: -->
<xsl:template name="incrementValue">
<xsl:param name="value"/>
<xsl:param name="invar"/>
<xsl:param name="stop"/>
<xsl:if test="$value <= $stop">
<xsl:choose>
<xsl:when test="$value=$invar">
<option value="{$value}" selected="selected">
<xsl:value-of select="$value"/>
</option>
</xsl:when>
<xsl:otherwise>
<option value="{$value}">
<xsl:value-of select="$value"/>
</option>
</xsl:otherwise>
</xsl:choose>
<xsl:call-template name="incrementValue">
<xsl:with-param name="value" select="$value + 1"/>
<xsl:with-param name="invar" select="$invar"></xsl:with-param>
<xsl:with-param name="stop" select="$stop"></xsl:with-param>
</xsl:call-template>
</xsl:if>
</xsl:template>
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe@l...>
--~--
Disclaimer
These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

