Subject: Re: [xsl] FW: Linear counting problem in nested loop From: Mukul Gandhi <mukulgandhi2003@xxxxxxxxxxx> Date: Sun, 25 Jan 2004 10:29:41 +0000 (GMT) |
Hi Dongzhi, Please try the following XSL template - <xsl:template match="/MENU"> <xsl:for-each select=".//*"> <xsl:if test="text()"> <xsl:value-of select="position() div 2"/> for <xsl:value-of select="text()"/> </xsl:if> </xsl:for-each> </xsl:template> Regards, Mukul --- "Wang, Dongzhi (ACF)" <DWang@xxxxxxxxxxx> wrote: > > Hi, > > I have the following XML and want to implement such > that I can have > a linear counter increment with each iteration of > the parent for-each > loop and also the nested for-each loop. > > <?xml version="1.0"?> > <MENU> > <MenuItems> > <MenuLabel>Menu 1</MenuLabel> > <SubMenuItems> > <SubMenuLabel>Sub Menu 1</SubMenuLabel> > </SubMenuItems> > <SubMenuItems> > <SubMenuLabel>Sub Menu > 11</SubMenuLabel> > </SubMenuItems> > </MenuItems> > <MenuItems> > <MenuLabel>Menu 2</MenuLabel> > <SubMenuItems> > <SubMenuLabel>Sub Menu 2</SubMenuLabel> > </SubMenuItems> > </MenuItems> > </MENU> > > e.g. The counter should return as: > 1 for Menu 1 > 2 for SubMenu 1 > 3 for SubMenu 11 > 4 for Menu 2 > 5 for SubMenu 2 > > So far, what I got is the counter breaks when it > reaches the second > <MenuItems>, as it doesn't know about the subMenu > from the first > MenuItems counts 3 already... > > Thanks a lot! > Dongzhi > > XSL-List info and archive: > http://www.mulberrytech.com/xsl/xsl-list > ________________________________________________________________________ Yahoo! India Mobile: Download the latest polyphonic ringtones. Go to http://in.mobile.yahoo.com XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] FW: Linear counting problem i, Wang, Dongzhi (ACF) | Thread | Re: [xsl] FW: Linear counting probl, G. Ken Holman |
[xsl] Re: Displaying XSLT XML resu, Dimitre Novatchev | Date | Re: [xsl] FW: Linear counting probl, G. Ken Holman |
Month |