This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
xsl:param problem
- To: <xsl-list at lists dot mulberrytech dot com>
- Subject: [xsl] xsl:param problem
- From: "Anand Jayaraman" <ajayaraman at yahoo dot com>
- Date: Thu, 9 Aug 2001 07:08:49 -0400
- Reply-To: xsl-list at lists dot mulberrytech dot com
Hi All,
I need some help in the following:
I'm trying to create 2 drop-down boxes, one selecting distinct month, and
the other selecting distinct days for a given month from the previous
drop-down box. Hope it is clear so far.
My XML file looks like:
<page>
<Audits>
<Audit AuditID="694" Year="2001">
<Day>15</Day>
<Month>JUL</Month>
<SourceFile>15Jul2001.01Aug20011650</SourceFile>
</Audit>
<Audit AuditID="705" Year="2001">
<Day>18</Day>
<Month>AUG</Month>
<SourceFile>18Aug2001.02Aug20011921</SourceFile>
</Audit>
<Audit AuditID="739" Year="2001">
<Day>18</Day>
<Month>JUL</Month>
<SourceFile>18Jul2001.04Aug20011612</SourceFile>
</Audit>
</Audits>
</page>
My desired output should be:
Month Dropdown = JUL (selected), AUG
Days Dropdown for 'JUL' = 15, 18
Below is my version of XSL file. I'm able to create a drop-down for distinct
months. But, am not able to get the distinct days for the first month, in
this case 'JUL'. Something is not correct with the way I'm passing
parameters.
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output method="html" />
<xsl:key name="mon-index" match="page/Audits/Audit" use="Month"/>
<xsl:param name="monthname" />
<xsl:template match="/">
<FORM NAME="blank_form">
<xsl:apply-templates select="page/Audits"/>
</FORM>
</xsl:template>
<xsl:template match="page/Audits">
<SELECT>
<xsl:attribute name="name">
<xsl:value-of select="'cycleMonth'"/>
</xsl:attribute>
<OPTION VALUE="cycleMonth">--MONTH--</OPTION>
<xsl:for-each
select="Audit/Month[generate-id(.)=generate-id(key('mon-index',.)[1]/Month)]
">
<OPTION>
<xsl:sort select="."/>
<xsl:with-param name="monthname" >
<xsl:value-of select="."/>
</xsl:with-param>
<xsl:attribute name="value">
<xsl:value-of select="."/>
</xsl:attribute>
<xsl:value-of select="."/>
</OPTION>
</xsl:for-each>
</SELECT>
<SELECT>
<xsl:attribute name="name">
<xsl:value-of select="'cycleDay'"/>
</xsl:attribute>
<OPTION VALUE="cycleDay">--DAY--</OPTION>
<xsl:param name="monthname"/>
<xsl:for-each select="key('mon-index',$monthname)">
<OPTION>
<xsl:sort select="Month"/>
<xsl:attribute name="value">
<xsl:value-of select="Day"/>
</xsl:attribute>
<xsl:value-of select="Day"/>
</OPTION>
</xsl:for-each>
</SELECT>
</xsl:template>
</xsl:stylesheet>
_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list