This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: more attribute fun...
- From: Jeni Tennison <jeni at jenitennison dot com>
- To: bryan hansen <bh5k at yahoo dot com>
- Cc: xsl-list at lists dot mulberrytech dot com
- Date: Tue, 19 Mar 2002 09:27:53 +0000
- Subject: Re: [xsl] more attribute fun...
- Organization: Jeni Tennison Consulting Ltd
- References: <20020318230629.72269.qmail@web12705.mail.yahoo.com>
- Reply-to: xsl-list at lists dot mulberrytech dot com
Hi Bryan,
> This worked great, but now I was wondering about calculating
> something in an attribute and then outputing the result. What I mean
> by this is something to the effect of:
>
> <path d="M 35... fill="{fill_percentage > 90 ? green :
> yellow}" />
If you were after something short and incomprehensible, you could use:
<path fill="{substring('yellow green',
(fill_percentage > 90) * 7 + 1, 6)}" />
if fill_percentage > 90 is true (1), then multiplying by 7 gives you 7,
plus 1 is 8, so you get the substring of 'yellow green' starting at
the 8th character ('g') and 6 characters long (the rest of the
string). If fill_percentage > 90 is false (0), then multiplying by 7
gives you 0, plus 1 is 1, so you get the substring of 'yellow green'
starting at the 1st character ('y') and 6 characters long (the string
'yellow').
Cheers,
Jeni
---
Jeni Tennison
http://www.jenitennison.com/
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list