This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
RE: Conditional Formating
- To: xsl-list at lists dot mulberrytech dot com
- Subject: RE: [xsl] Conditional Formating
- From: sara dot mitchell at ps dot ge dot com
- Date: Tue, 2 Jan 2001 14:57:20 -0500
- Reply-To: xsl-list at lists dot mulberrytech dot com
One way to do this is to use multiple templates for matching
MONTH with a predicate on the CALENDAR ancestor specifying
your test. For example:
<!-- this template matches the MONTH element only if it's
ancestor CALENDAR has a WEEK value for MYFORMAT -->
<xsl:template match="CALENDAR[@MYFORMAT='WEEK']/MONTHS/MONTH">
<td>You selected myformat of type week.</td>
</xsl:template>
<xsl:template match="CALENDAR[@MYFORMAT='DAY']/MONTHS/MONTH">
<td>You selected myformat of type day.</td>
</xsl:template>
<!-- If MYFORMAT is optional and may not be set, you also
need a default template to handle this -->
<xsl:template match="CALENDAR[not(@MYFORMAT)]/MONTHS/MONTH">
<td>You did not select a calendar format.</td>
</xsl:template>
Sara
> -----Original Message-----
> From: David Vogt [mailto:dvogt@power2000.com]
> Sent: Tuesday, January 02, 2001 10:00 AM
> To: xsl-list@lists.mulberrytech.com
> Subject: [xsl] Conditional Formating
>
>
> I need to do some conditional formatting.
> I'm a couple apply-templates deep into the tree. At that
> point, within the
> test of a choose/when, I'd like to reference a attribute of
> the root of the
> tree, or a element off of the root of the tree, or something
> else that would
> be better.
>
> so, my xml might look like this:
>
> <CALENDAR MYFORMAT="WEEK">
> <MYFORMAT>WEEK</MYFORMAT>
> <MONTHS>
> <MONTH>
> </MONTH>
> <MONTH>
> </MONTH>
> ...
> </MONTHS>
> </CALENDAR>
>
> I'd like to have some xsl like this but it's not referencing
> the value of
> the MYFORMAT correctly.
>
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
>
> <xsl:output method="html"/>
>
> <xsl:template match="*|/"><xsl:apply-templates/></xsl:template>
>
> <xsl:template match="text()|@*"><xsl:value-of
> select="."/></xsl:template>
>
> <xsl:template match="/">
>
> <xsl:apply-templates/>
>
> <xsl:template match="CALENDAR">
> <xsl:apply-templates select="MONTHS">
> </xsl:apply-templates>
> </xsl:template>
>
> <xsl:template match="MONTHS">
> <xsl:apply templates select="MONTH">
> </xsl:apply-templates>
> </xsl:template>
>
> <xsl:template match="MONTH">
> <xsl:choose>
> <xsl:when test="MYFORMAT='WEEK'">
> <td>You selected myformat of type week.</td>
> </xsl:when>
> </xsl:choose>
> </xsl:template>
>
> Basically, how do I get the xsl:when test=... to work???
>
> Thanks,
> Dave
>
> Mark Your Calendar!
> SilverSummit 2001, April 8-12, Walt Disney World Dolphin Hotel
> <http://www.silverstream.com/userconference>>
> SILVERSTREAM's eBUSINESS PLATFORM in action: Visit:
> <http://www.CivicLife.com>
> This solution realizes the vision of a "Citizen-Centric Civic
> World" by
> harnessing the Internet
> to enable personal, real-time interactions between citizens
> and their civic
> institutions.
> To learn more about this and other SilverStream eBusiness
> solutions visit:
> <http://www.silverstream.com/customers>>
>
>
>
> XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
>
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list