Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

alternating line colours 1

Status
Not open for further replies.

emms

Programmer
Jan 11, 2001
55
0
0
GB
Hi,

I'm having huge trouble with some XSL.

I'm trying to output XML with alternate lines coloured differently... so far I've got this:

<xsl:variable name=&quot;row-number&quot; select=&quot;position()&quot;/>
<tr class=&quot;
<xsl:choose>
<xsl:when test=&quot;$row-number mod 2 = 0&quot;>darkrow</xsl:when>
<xsl:eek:therwise>lightrow</xsl:eek:therwise>
</xsl:choose>&quot;>

can anyone tell me what I'm doing wrong... the error is:
The character '<' cannot be used in an attribute value


This is the first XSL I've written and I'm picking it up as I go along from the net... be gentle!

thanks

Emma
 
Hello.

Try this:

Code:
<xsl:variable name=&quot;row-number&quot; select=&quot;position()&quot;/>

<tr>
  <xsl:attribute name=&quot;class&quot;>
    <xsl:choose>
      <xsl:when test=&quot;$row-number mod 2 = 0&quot;>darkrow</xsl:when>
      <xsl:otherwise>lightrow</xsl:otherwise>
    </xsl:choose>
  </xsl:attribute>

  <td>blah blah</td>

</tr>

The error you got arose because you used the
Code:
<
symbol when it wasn't really an element.

You need to use the <xsl:attribute> element when you are generating attribute values from the XML.

:)
 
Oh I see!

thanks you're an absolute star.

[sunshine]

that's solved about five nagging problems I was having.

Em
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top