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

doubt regarding position() mod 2

Subject: doubt regarding position() mod 2
From: "Anand Ganapathy" <Anand.Ganapathy@xxxxxx>
Date: Tue, 23 Apr 2002 12:45:02 +0530
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


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.