|
Subject: Re: [xsl] using position to change row colors From: "David B. Bitton" <david@xxxxxxxxxxxxxx> Date: Mon, 12 Nov 2001 23:12:45 -0500 |
Amy,
Much easier to do. Just put this in the TR
<tr class="cell{position() mod 2}>
The output will be either 'class="cell1"' or 'class="cell0"'. Now, just add those classes to
your CSS style sheet, and you'll be on your way.
On Mon, Nov 12, 2001 at 05:45:07PM -0800, Amy Kaizerman wrote:
>
> Hi everyone. I realize this is described in the XSL doc at w3c. What
> I'm running into is confusion
> about what node I'm at, at least I think that's it, or it maybe a
> boundary condition problem?
>
> Here's my XSL:
>
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> xmlns:Aps="http://www.assist.com/"
> xmlns:xalan="http://xml.apache.org/xalan"
> xmlns:ino="http://namespaces.softwareag.com/tamino/response2"
> exclude-result-prefixes="Aps xalan ino">
> <xsl:output method="html" indent="yes"/>
> <xsl:param name="Name" select="."/>
>
> <xsl:template match="/">
>
> <xsl:for-each select="Aps:VpmResultSet/Aps:PartStructure">
> <xsl:for-each select="xalan:evaluate($Name)">
> <tr>
> <xsl:choose>
> <xsl:when test="position() mod 2 = 0">
> <xsl:attribute name="class">dark</xsl:attribute>
> </xsl:when>
> <xsl:when test="position() mod 2 = 1">
> <xsl:attribute name="class">light</xsl:attribute>
> </xsl:when>
> </xsl:choose>
>
> <td><xsl:value-of
> select="ancestor::Aps:PartStructure/Aps:Name"/></td>
> <td><xsl:value-of
> select="ancestor::Aps:PartStructure/Aps:TopAssemblyName"/></td>
> <td><xsl:value-of
> select="ancestor::Aps:PartStructure/Aps:PartNumber"/></td>
> <td><xsl:value-of select="Aps:DocumentId"/></td>
> <td><a><xsl:attribute
> name="href">/assist/model/apsVpmSheets/?id=<xsl:value-of
> select="ancestor::Aps:PartStructure/@ino:id"/>&type=<xsl:value-of
> select="$Name"/>&name=<xsl:value-of select="Aps:Name"/>
> </xsl:attribute><xsl:value-of select="Aps:Name"/>
> </a></td>
> </tr>
> </xsl:for-each>
> </xsl:for-each>
> </xsl:template>
> </xsl:stylesheet>
>
> And my XML (a very small section of it) :
>
> <?xml version="1.0"?>
> <Aps:VpmResultSet xmlns:Aps="http://www.assist.com/">
> <Aps:PartStructure xmlns:Aps="http://www.assist.com/">
> <Aps:Name>tmp2</Aps:Name>
> <Aps:AsDesigned>
> <Aps:Drawing>
> <Aps:Name>another thing 2</Aps:Name>
> <Aps:Author>CM 2</Aps:Author>
> </Aps:Drawing>
> <Aps:Model>
> <Aps:Name>a file</Aps:Name>
> <Aps:Author>Amy</Aps:Author>
> </Aps:Model>
> </Aps:AsDesigned>
> </Aps:PartStructure>
> <Aps:PartStructure xmlns:Aps="http://www.assist.com/">
> <Aps:Name>tmp2</Aps:Name>
> <Aps:AsDesigned>
> <Aps:Drawing>
> <Aps:Name>another thing</Aps:Name>
> <Aps:Author>CM</Aps:Author>
> </Aps:Drawing>
> <Aps:Drawing>
> <Aps:Name>another thing 2</Aps:Name>
> <Aps:Author>CM 2</Aps:Author>
> </Aps:Drawing>
> <Aps:Model>
> <Aps:Name>a file</Aps:Name>
> <Aps:Author>Amy</Aps:Author>
> </Aps:Model>
> </Aps:AsDesigned>
> </Aps:PartStructure>
> </Aps:VpmResultSet>
>
> What happens is I get light, light, dark in <tr class="">. What I want
> is for every row
> of the table to have alternating colors, or light, dark, light.
>
> I also realize that this isn't be best looking XSLT. I have another one
> that uses apply-templates,
> but I had a lot of trouble getting that to work after I started needing
> to pass in a param and using
> xalan:evaluate(). If you have pointers on how to make this look better
> I'd appreciate that too.
>
> Mostly though I'd like to get my colors worked out.
>
> Can anybody help me?
>
> Amy
>
>
> XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
--
David B. Bitton
david@xxxxxxxxxxxxxx
Diversa ab illis virtute valemus.
Attachment:
pgp00004.pgp
Description: PGP signature
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| [xsl] using position to change row , Amy Kaizerman | Thread | RE: [xsl] using position to change , Jarno . Elovirta |
| [xsl] using position to change row , Amy Kaizerman | Date | RE: [xsl] using position to change , Jarno . Elovirta |
| Month |