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

Re: using position to change row colors

Subject: Re: using position to change row colors
From: "David B. Bitton" <david@xxxxxxxxxxxxxx>
Date: Mon, 12 Nov 2001 23:12:45 -0500
css change row
--8P1HSweYDcXXzwPJ
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

Amy,
	Much easier to do.  Just put this in the TR

	<tr class=3D"cell{position() mod 2}>

The output will be either 'class=3D"cell1"' or 'class=3D"cell0"'.  Now, jus=
t add those classes to
your CSS style sheet, and you'll be on your way.=20

On Mon, Nov 12, 2001 at 05:45:07PM -0800, Amy Kaizerman wrote:
>=20
> 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?
>=20
> Here's my XSL:
>=20
> <xsl:stylesheet version=3D"1.0"
>  xmlns:xsl=3D"http://www.w3.org/1999/XSL/Transform"
>  xmlns:Aps=3D"http://www.assist.com/"
>  xmlns:xalan=3D"http://xml.apache.org/xalan"
>         xmlns:ino=3D"http://namespaces.softwareag.com/tamino/response2"
>  exclude-result-prefixes=3D"Aps xalan ino">
>   <xsl:output method=3D"html" indent=3D"yes"/>
>   <xsl:param name=3D"Name" select=3D"."/>
>=20
>   <xsl:template match=3D"/">
>=20
>     <xsl:for-each select=3D"Aps:VpmResultSet/Aps:PartStructure">
>       <xsl:for-each select=3D"xalan:evaluate($Name)">
>       <tr>
>         <xsl:choose>
>    <xsl:when test=3D"position() mod 2 =3D 0">
>      <xsl:attribute name=3D"class">dark</xsl:attribute>
>           </xsl:when>
>    <xsl:when test=3D"position() mod 2 =3D 1">
>      <xsl:attribute name=3D"class">light</xsl:attribute>
>           </xsl:when>
>         </xsl:choose>
>=20
>         <td><xsl:value-of
> select=3D"ancestor::Aps:PartStructure/Aps:Name"/></td>
>         <td><xsl:value-of
>    select=3D"ancestor::Aps:PartStructure/Aps:TopAssemblyName"/></td>
>         <td><xsl:value-of
>    select=3D"ancestor::Aps:PartStructure/Aps:PartNumber"/></td>
>         <td><xsl:value-of select=3D"Aps:DocumentId"/></td>
>         <td><a><xsl:attribute
> name=3D"href">/assist/model/apsVpmSheets/?id=3D<xsl:value-of
> select=3D"ancestor::Aps:PartStructure/@ino:id"/>&amp;type=3D<xsl:value-of
> select=3D"$Name"/>&amp;name=3D<xsl:value-of select=3D"Aps:Name"/>
>             </xsl:attribute><xsl:value-of select=3D"Aps:Name"/>
>         </a></td>
>       </tr>
>       </xsl:for-each>
>     </xsl:for-each>
>   </xsl:template>
> </xsl:stylesheet>
>=20
> And my XML (a very small section of it) :
>=20
> <?xml version=3D"1.0"?>
> <Aps:VpmResultSet xmlns:Aps=3D"http://www.assist.com/">
> <Aps:PartStructure xmlns:Aps=3D"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=3D"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>
>=20
> What happens is I get light, light, dark in <tr class=3D"">.  What I want
> is for every row
> of the table to have alternating colors, or light, dark, light.
>=20
> 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.
>=20
> Mostly though I'd like to get my colors worked out.
>=20
> Can anybody help me?
>=20
> Amy
>=20
>=20
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

--=20

David B. Bitton
david@xxxxxxxxxxxxxx

Diversa ab illis virtute valemus.

--8P1HSweYDcXXzwPJ
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE78J28MNOMzNRRk50RAj69AJ9R6qeFnd8eWAwbGjeLbtOkLFtrdQCgq2ym
fXUL1MHi2LBlK/pKD3Khi/o=
=9ylz
-----END PGP SIGNATURE-----

--8P1HSweYDcXXzwPJ--

 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.