[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
At 2004-01-24 13:47 -0500, Wang, Dongzhi (ACF) wrote:
This has just recently been discussed on this list and the use of counters is a classical programming approach that cannot be employed easily (or at all in some cases) in XSLT. XSLT provides facilities for hierarchical processing of XML documents.
I supplied two one-line solutions to this problem in the following post:
http://www.biglist.com/lists/xsl-list/archives/200401/msg00884.html
I hope this helps.
.................... Ken
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Re: [xsl] FW: Linear counting problem in nested loop
Subject: Re: [xsl] FW: Linear counting problem in nested loop From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx> Date: Sun, 25 Jan 2004 08:44:47 -0500 |
At 2004-01-24 13:47 -0500, Wang, Dongzhi (ACF) wrote:
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.
This has just recently been discussed on this list and the use of counters is a classical programming approach that cannot be employed easily (or at all in some cases) in XSLT. XSLT provides facilities for hierarchical processing of XML documents.
I supplied two one-line solutions to this problem in the following post:
http://www.biglist.com/lists/xsl-list/archives/200401/msg00884.html
I hope this helps.
.................... Ken
<?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
-- Public courses: sign up for one or both soon to reserve your seat! Each week: Monday-Wednesday: XSLT/XPath; Thursday-Friday: XSL-FO Washington, DC: 2004-03-15 San Francisco, CA: 2004-03-22 Hong Kong, China: 2004-05-17 Bremen, Germany: 2004-05-24 World-wide on-site corporate, government & user group XML training
G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ Box 266, Kars, Ontario CANADA K0A-2E0 +1(613)489-0999 (F:-0995) Male Breast Cancer Awareness http://www.CraneSoftwrights.com/s/bc
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] FW: Linear counting probl, G. Ken Holman | Thread | RE: [xsl] FW: Linear counting probl, Mischa Sandberg |
Re: [xsl] FW: Linear counting probl, Mukul Gandhi | Date | Re: [xsl] FW: Linear counting probl, G. Ken Holman |
Month |