Subject: Re: [xsl] doubt regarding position() mod 2 From: "David B. Bitton" <david@xxxxxxxxxxxxxx> Date: Tue, 23 Apr 2002 09:42:49 -0400 |
Ahhhh. Ok, try this: ... <tr class="row{position() mod 2}"> ... That is _all_ you need. Now just create a CSS stylesheet that has row0 and row1 classes. The curly braces (and it's content) is translated to output, so you would get this: odd row: <tr class="row1"> even row: <tr class="row0"> This comes up quite frequently. Perhaps this example should be enshrined somewhere. -- David B. Bitton david@xxxxxxxxxxxxxx www.codenoevil.com Code Made Fresh DailyT ----- Original Message ----- From: "Anand Ganapathy" <Anand.Ganapathy@xxxxxx> To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx> Sent: Tuesday, April 23, 2002 3:15 AM Subject: [xsl] doubt regarding position() mod 2 > Hello, > I have begun working on XSL recently. > > I have written an XSL to convert my XML into an html which displays the xml as a tree. > > My XML is as given below: > <?xml version="1.0" encoding="UTF-8"?> > <NODE1> > <NODEADDRESS>1</NODEADDRESS> > <LEVELIDENTIFIER>1</LEVELIDENTIFIER> > <NODENAME>All Products </NODENAME> > <NODE2> > <NODEADDRESS>1:1</NODEADDRESS> > <LEVELIDENTIFIER>2</LEVELIDENTIFIER> > <NODENAME>Meat </NODENAME> > <NODE3> > <NODEADDRESS>1:1:1</NODEADDRESS> > <LEVELIDENTIFIER>3</LEVELIDENTIFIER> > <NODENAME>Eggs </NODENAME> > </NODE3> > <NODE3> > <NODEADDRESS>1:1:2</NODEADDRESS> > <LEVELIDENTIFIER>3</LEVELIDENTIFIER> > <NODENAME>Red Meat </NODENAME> > </NODE3> > </NODE2> > <NODE2> > <NODEADDRESS>1:2</NODEADDRESS> > <LEVELIDENTIFIER>2</LEVELIDENTIFIER> > <NODENAME>Dairy </NODENAME> > </NODE2> > <NODE2> > <NODEADDRESS>1:3</NODEADDRESS> > <LEVELIDENTIFIER>2</LEVELIDENTIFIER> > <NODENAME> Chocolate </NODENAME> > </NODE2> > </NODE1> > > I need to display each alternating <NODENAME>element under <NODE2> in a different color. > In my XSL, I tried using a test condition <xsl:if test="position() mod 2 = 1">, > This test condition should return true for any item element that is an odd-numbered item child of its parent and hence 'Meat' and 'Chocolate' should be diplayed in the same color whereas 'Dairy' should be in a different color. > However, I am getting all these in the same color.Could you please tell me where I am going wrong.Or is there a better way of achieving the same? > > Anand. > > > > > > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] doubt regarding position(, cutlass | Thread | RE: [xsl] doubt regarding position(, Anand Ganapathy |
RE: [xsl] key match and x-path prob, Kevin Jones | Date | RE: [xsl] next sibling, Brinkman, Theodore |
Month |