[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

using position to change row colors

Subject: using position to change row colors
From: Amy Kaizerman <amy.j.kaizerman@xxxxxxxx>
Date: Mon, 12 Nov 2001 17:45:07 -0800
using position in xslt
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"/>&amp;type=<xsl:value-of
select="$Name"/>&amp;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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.