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

RE: Conditional Formating

Subject: RE: Conditional Formating
From: sara.mitchell@xxxxxxxxx
Date: Tue, 2 Jan 2001 14:57:20 -0500
xsl conditional formatting
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@xxxxxxxxxxxxx]
> Sent: Tuesday, January 02, 2001 10:00 AM
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  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


Current Thread

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.