[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

[no subject]

From: kommersz <kommersz@xxxxxxxxxxx>
Date: Tue, 21 Oct 2003 08:31:28 +0200 (CEST)
dropdownlist month names january december

  Hi all!

I'm about to create some dropdown boxes in a HTML page,
which contains months, and can be selected with an index
value in an xml file.
For example:

<monthrange>
 <from>2</from>
 <to>6</to>
</monthrange>

where from=2 should mean march, ad to=6 should mean july.

I'd like to create a callable template, with a parameter
given, which outputs an html fragment like this:

<option value="0">January</option>
<option value="1">February</option>
<option value="2" selected="1">March</option>
<option value="3">April</option>
.
.
.
<option value="11">December</option>

My question is, if there is an easy way to enumerate months
as  predefined values, so I can create the callable template
something like this:

<xsl:for-each select="MONTHS">
 <xsl:element name="option">
  <xsl:attribute name="value"><xsl:value-of
select="position()-1" /></xsl:attribute>
   <xsl:if test="number($selected)=position()-1">
    <xsl:attribute name="selected">1</xsl:attribute>
   </xsl:if>
   <xsl:value-of select="NAME"/>
 </xsl:element>
</xsl:for-each>

where $selected is the selected elements index, and NAME
should be (as I imagine) something like this:
<MONTHS>
 <NAME>January</NAME>
 <NAME>February</NAME>
 .
 .
 .
 <NAME>December</NAME>
</MONTHS>

I would really like to avoid listing all month options as
<xsl:element> declarations.

Best would be if the above could be declared in a separate
file, so I could call it from any stylesheets I use.

  Probably it's an  annoying question, as it must be
something obvious, but I could not find the way to solve this.



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread
  • [no subject]
    • kommersz - Tue, 21 Oct 2003 02:31:37 -0400 (EDT) <=

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.