This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

using position to change row colors



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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]