Re: Simple Conditionals

Subject: Re: Simple Conditionals
From: "James Tauber" <jtauber@xxxxxxxxxxx>
Date: Fri, 16 Apr 1999 08:29:20 +0800
> Can XSL do processing conditional?

It certainly can. Quite powerfully, actually.

  What I'm looking to do is color the rows
> of my table based on an element's attribute.
>
> For example:
> <entry type="type1">
>  <body>text</body>
> </entry>
>
> <entry type="type2">
> <body>more text</body>
> </entry>
>
> The xsl would then create a table, and place the body text for each entry
in
> its own row.  Entries of type1 should have a text color of red, and
entries
> of type 2 should be blue.

<template match='entry[@type="type1"]/body'>
  <html:td><html:font color="red"><apply-templates/></html:font></html:td>
</template>

<template match='entry[@type="type2"]/body'>
  <html:td><html:font color="blue"><apply-templates/></html:font></html:td>
</template>

For most powerful conditions, have a look at choose, when and otherwise.
There is an example at
http://www.xmlsoftware.com/articles/xsl-by-example.html

Hope this helps.


James
--
James Tauber / jtauber@xxxxxxxxxxx / www.jtauber.com
XML Standards and Product Coordinator
HarvestRoad Communications / www.harvestroad.com.au

Full-day XML Tutorial @ WWW8 : http://www8.org/

Maintainer of : www.xmlinfo.com,  www.xmlsoftware.com and www.schema.net



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread