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

How to calculate attribute values with XSL ?

Subject: How to calculate attribute values with XSL ?
From: stig.garberg@xxxxxxxxxx
Date: Tue, 8 Jan 2002 09:24:39 +0100
stig garberg

I'm working with working with XSL for HTML output.   A problem that has occured
several times is that I want to calculate the values of HTML attributes based on
input XML values, but I'm not able to find a sensible way to do it.

For instance if I want to change the background colour (bccolor attribute) of a
table row based on the XML tags <state> and <ack>, where (<state>on</state> and
<ack>off</ack>) shall give bgcolor="#ff0000", while  (<state>on</state> and
<ack>on</ack>) shall give bgcolor="#008000".

I can solve this by writing :
   <xsl:if test="state = 'on' and ack = 'off'">
      <tr bgcolor="#ff0000">table contents</tr>
   </if>
   <xsl:if test="state = 'on' and ack = 'on'">
      <tr bgcolor="#008000">table contents</tr>
   </if>

However, if there is a large table, it feels meaningless to write the table
contents multiple times.  Is there a better way of solving this problem by
calculating the attribute value directly?

/StiG



 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.