Subject: Re: [xsl] Setting background colour according to contents of node From: "M. David Peterson" <m.david@xxxxxxxxxx> Date: Sat, 18 Sep 2004 23:21:18 -0700 |
<?xml version="1.0"?> <data> <table bgcolor="w"/> <table bgcolor="b"/> </data>
<bgcolor:colors> <color test="w">#fff</color> <color test="b">#000</color> </bgcolor:colors>
<xsl:template match="/"> <xsl:apply-templates select="data/table"/> </xsl:template>
<table style="background: #fff"/> <table style="background: #000"/>
Hi all, I was trying to set a background colour by setting a variable after checking the contents of a node. I realized that this would not work unless I used LOTS of variables since the value of a variable cannot be updated once set. Does anyone have an easier way to set a colour based on data? The only other way I can think of is to use an <xsl:choose> but then I have to repeat my whole table cell code twice (which really adds up for large reports).
This is what I currently have (which is pretty awful):
<xsl:choose> <xsl:when test="BREAK_3/FIELD_134[1]=Y or BREAK_3/FIELD_135[1]='F'"> <fo:table-cell background-color="#9DE1DF"> .... contents of the cell .... </fo:table-cell> </xsl:when>
<xsl:otherwise> <fo:table-cell background-color="white">...exactly the same code for the contents...</fo:table-cell> </xsl:otherwise> </xsl:choose>
TIA for listening to my silly question, Helen.
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Setting background colour acc, Sean & Helen | Thread | RE: [xsl] Setting background colour, Michael Kay |
[xsl] Using a parameter in a select, Sean & Helen | Date | Re: [xsl] Ideas for creating quotat, Steffen Glückselig |
Month |