This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
RE: Using XPath expressions in modes
- To: xsl-list at lists dot mulberrytech dot com
- Subject: RE: [xsl] Using XPath expressions in modes
- From: Meltem Kogelbauer <meltem dot kogelbauer at netdecisions dot co dot uk>
- Date: Tue, 24 Apr 2001 18:00:40 +0100
- Reply-To: xsl-list at lists dot mulberrytech dot com
<xsl:param name="mode"/>
should be after
<xsl:template match="page">
like -----
<xsl:template match="page">
<xsl:param name="mode"/>
Meltem
-----Original Message-----
From: William Bagby [mailto:williamb@adone.com]
Sent: 24 April 2001 4:54 PM
To: XSL Mailing List (E-mail)
Subject: [xsl] Using XPath expressions in modes
This seems like a very basic question, but I wasn't able to locate the
answer to this on any FAQs....
I have a list of categories, and I would like it to be displayed differently
based on URL params:
XML-----------------------------------------
<page>
...
<category-list>
<category>...</category>
<category>...</category>
<category>...</category>
<category>...</category>
<category>...</category>
</category-list>
...
</page>
XSL------------------------------------------
<xsl:param name="mode"/>
<xsl:template match="page">
...
<xsl:if test="$mode">
<xsl:apply-templates select="category-list" mode="$mode"/>
</xsl:if>
<xsl:if test="not($mode)">
<xsl:apply-templates select="category-list" mode="default"/>
</xsl:if>
...
</xsl:template>
<xsl:template match="category-list" mode="default">
<!-- display as Table -->
<table border="0" cellpadding="0" cellspacing="0" width="200"
bgcolor="#000000">
<xsl:for-each select="category">
<tr><td><xsl:value-of select="."/></td></tr>
</xsl:for-each>
</table>
</xsl:template>
<xsl:template match="category-list" mode="dropdown">
<!-- display as dropdown list -->
<form action=".." method="get">
<select name="cat">
<xsl:for-each select="category">
<option value="{.}"><xsl:value-of
select="."/></option>
</xsl:for-each>
</select>
<input type="submit"/>
</form>
</xsl:template>
etc, etc....
Using $mode doesn't seem to work. Is it even legal? Or is there a better
way of doing this?
Thanks in advance, and my apologies if this is in the FAQ already.
William.
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list