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]
Other format: [Raw text]

RE: doubt regarding position() mod 2


Check this example given in this url.


http://www.topxml.com/snippetcentral/main.asp?view=viewsnippet&lang=xpath&id
=v20010125232950


Cheers!!
Sachi

-----Original Message-----
From: owner-xsl-list@lists.mulberrytech.com
[mailto:owner-xsl-list@lists.mulberrytech.com]On Behalf Of Anand
Ganapathy
Sent: Tuesday, April 23, 2002 12:45 PM
To: xsl-list@lists.mulberrytech.com
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


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