This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Using XPath expressions in modes
- To: "XSL Mailing List (E-mail)" <xsl-list at lists dot mulberrytech dot com>
- Subject: [xsl] Using XPath expressions in modes
- From: William Bagby <williamb at adone dot com>
- Date: Tue, 24 Apr 2001 11:54:00 -0400
- Reply-To: xsl-list at lists dot mulberrytech dot com
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