[Date Prev]
| [Thread Prev]
| [Thread Next]
| [Date Next]
--
[Date Index]
| [Thread Index]
Re: [xml-dev] Conditionally formatting a HTML table row using XML/XSL
- From: Peter Flynn <peter@silmaril.ie>
- To: xml-dev@lists.xml.org
- Date: Sun, 27 Feb 2022 15:46:30 +0000
On 27/02/2022 12:38, Richard Watt wrote:
> Hi Matthias,
>
> My apologies - that's me remembering the tags incorrectly: it's using
> <xsl:attribute name="class"> </xsl:attribute>, and the actual XSL reads as:
>
> <TR><xsl:if test="ORDERSTATUS='Completed'"> <xsl:attribute-value
> name="class">trCompleted</xsl:attribute> </xsl:if>
>
> Unfortunately, this doesn't work - the order details are always
> displayed in black regardless of the order status.
There is no such element type as xsl:attribute-value as far as I know.
It would be very useful for those of us who write documentation if you
could let us know where you found it.
What you need is
<tr>
<xsl:if test="ORDERSTATUS='Completed'">
<xsl:attribute name="class">
<xsl:text>trCompleted</text>
</xsl:attribute>
</xsl:if>
...whatever else...
</tr>
I am assuming the <ORDERSTATUS> really is the name of an element type,
and not the name of an attribute, and that it is a child element of the
context in which this template is fired.
If you are repeating this structure for other values, consider making
the class value the value of ORDERSTATUS, eg
<tr class="tr{ORDERSTATUS}">
...
</tr>
Peter
[Date Prev]
| [Thread Prev]
| [Thread Next]
| [Date Next]
--
[Date Index]
| [Thread Index]