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

RE: comparing the valie of an attribute..

Subject: RE: comparing the valie of an attribute..
From: sara.mitchell@xxxxxxxxx
Date: Mon, 8 Jan 2001 19:26:31 -0500
place valie
There are a couple of ways to do this (and more I'm sure).
You can use xsl:choose or simply use different templates. 

Here's the multiple template way: 

<xsl:template match="event[@type='debug']">
<!-- make background color gray -->
<td bgcolor="#dddddd">
 ...what ever your cell content should be here...
</td>
</xsl:template> 

<xsl:template match="event[@type='error']">
<!-- make background color ref -->
<td bgcolor="#990000">
 ...what ever your cell content should be here...
</td>
</xsl:template> 

Debug event elements will match the first template and have a 
gray background while error events will match the second template
and have a red background (very dark in this case). 

To use xsl:choose, you can do something like this: 

<xsl:template match="event">
<!-- set variable based on the value of type attribute -->
<xsl:variable name="colortype">
<xsl:choose>
<xsl:when test="@type='error'">#990000</xsl:when>
<xsl:otherwise>#dddddd</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<td>
<!-- assign background color using variable -->
<xsl:attribute name="bgcolor"><xsl:value-of select="$colortype"/>
</xsl:attribute> 
 ...what ever your cell content should be here...
</td>
</xsl:template>

<!-- make background color gray -->
<td bgcolor="#dddddd">
 ...what ever your cell content should be here...
</td>
</xsl:template> 

Sara


> -----Original Message-----
> From: Eduardo Dominguez [mailto:edmz@xxxxxxxxxxxxxx]
> Sent: Monday, January 08, 2001 1:22 PM
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  comparing the valie of an attribute..
> 
> 
> Having a xml log file with the following format:
> 
> 
> <eventlog>
> <event time='0.00000' place='function' line='95' delta='0.0'
> type='debug'>Program started</event>
> <event time='0.00437' place='unknown' line='???' delta='0.00437'
> type='error'>Bad argument</event>
> <event time='0.00670' place='GetResourcesByType()' line='217'
> delta='0.00233' type='query'>SELECT DISTINCT defs.id_resource as
> resource_id, defs.vc_description as description,  defs.vc_path as
> path,</event>
> </eventlog>
> 
> 
> as you can see, its just a list of events, thats all there is.
> I am learning xsl, so I decided to implement my debugging with it.
> I have my very basic xsl files that converts this data into 
> an html table.
> What I am trying to do now, is put a row in diferent color depending
> on the type attribute.
> I tried with xsl:choose, but I just couldnt use the attribute value
> for comparison.
> 
> Any help achieving this is appreciated...
> 
> thanks for helping a newbie :)
> 
> 
> 
>  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.