[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Trouble using recursion to make a Counter
Hi,
This can be accomplished with recursion, but why? It is generally much easier to do either of two things to get this kind of output: * Each time you match an item that you want, count all the items you want that precede it and add 1. * Or, simply use <xsl:number/>, which does this for you. "Unique sequential numbers" is exactly what it gives you. For example, you could say: <xsl:template match="Level1"/> <xsl:number count="Level1|Level2|Level3" level="any"/> <xsl:apply-templates select="Level1Desc"/> <xsl:apply-templates select="Level2"/> </xsl:template> etc. (Any good reference will tell you details about xsl:number, which is very versatile.) (BTW, if this truly is a recursive structure you'd find it easier to name everything "Level", "Desc" and so on, not hard-coding the particular level you are on but letting XSLT take care of that when necessary.) If you could clarify your requirements we'd have more confidence as to whether recursion is necessary. In any case (even if it proves to be) it's hard to help you figure it out without any indication of what you've tried so far. Cheers, Wendell At 05:51 PM 7/29/2004, you wrote: Hello! I've been struggling with something that seemed very simple when I first started looking at it, but has become frustrating. I have hit the archives and google, yet have found nothing to spark my imagination. All I need is to process my xml and for each node that I process increment and print a counter to the result file. ====================================================================== Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx Mulberry Technologies, Inc. http://www.mulberrytech.com 17 West Jefferson Street Direct Phone: 301/315-9635 Suite 207 Phone: 301/315-9631 Rockville, MD 20850 Fax: 301/315-8285 ---------------------------------------------------------------------- Mulberry Technologies: A Consultancy Specializing in SGML and XML ======================================================================
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|