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

RE: xsl:if statement with numeric

Subject: RE: xsl:if statement with numeric
From: "Michael Kay" <mhk@xxxxxxxxx>
Date: Sun, 28 Mar 2004 17:47:50 +0100
if statement in xml
Your first mistake is that

 <td bgcolor="$farbe" align="right">

should be

 <td bgcolor="{$farbe}" align="right">

This will then tell you your second mistake, which is that the variable
$farbe has gone out of scope (its scope is the <xsl:if> in which it is
declared). You need to declare it as:

<xsl:variable name="farbe">
  <xsl:choose>
  <xsl:when test=". &lt; 100.00">#00ff00</xsl:when>
  <xsl:otherwise>[eine andere farbe]</xsl:otherwise>
  </xsl:choose>
</xsl:variable>

Michael Kay 

# -----Original Message-----
# From: Tuan Luu [mailto:tuanluu@xxxxxx] 
# Sent: 28 March 2004 07:13
# To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
# Subject:  xsl:if statement with numeric
# 
# hello
# I'm very new to this. 
# I have an xml returned that looks like this: 
# 
# <td>100</td>
# <td>98.00</td>
# <td>100</td>
# 
# now I'd like to give the td tags different colors, depending 
# on the value.
# What I did so far ist that: 
# 
# <xsl:template match="monat">
#         <xsl:if test= "numeric(.) &lt; 100.00">     
#             <xsl:variable name="farbe">#00ff00</xsl:variable>
#         </xsl:if>
#     <td bgcolor="$farbe" align="right">
#         <xsl:apply-templates/>
#     </td>
# </xsl:template>
# 
# My problem is, I think he doesn't make a difference with the 
# value, all columns get the same color. 
# What have I done wrong here?
# Thanks for any answers.
# 
# -- 
# +++ NEU bei GMX und erstmalig in Deutschland: T\V-gepr|fter 
# Virenschutz 
# +++ +++
# 100% Virenerkennung nach Wildlist. Infos: 
# http://www.gmx.net/virenschutz
# 
# 
# 
# 

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.