Subject: Re: [xsl] number continuation problem From: David Carlisle <davidc@xxxxxxxxx> Date: Fri, 27 Jun 2003 10:20:35 +0100 |
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" > <xsl:template match="node"> .<xsl:value-of select=" 1 + count(preceding-sibling::node) + count(parent::if/preceding-sibling::if[count(node)>count(following-sibling::*[1][self::else]/node)]/node) + count(parent::else/preceding-sibling::if[position()>1][count(node)>count(following-sibling::*[1][self::else]/node)]/node) + count(../preceding-sibling::else[count(node)>=count(preceding-sibling::*[1][self::if]/node)]/node) "/>.<xsl:value-of select="."/> </xsl:template> </xsl:stylesheet> > Now, if you make it handle nested if/else's within nodes that would be > special :) depends how you want them to be counted. Since the code above only uses sibling and parent axes, not following or ancestor for example, it is naturally scoped to the parent of your sibling if and else nodes. So you should be able to make 1.2.3 style numbering easily enough. If however you actually want a continuous decimal numbering across nodes of arbitrary depth then more or less you would need to change preceding-sibling to preceding, and er, then change whatever else needs changing to what it needs changing to. David ________________________________________________________________________ This e-mail has been scanned for all viruses by Star Internet. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk ________________________________________________________________________ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] number continuation probl, Andrew Welch | Thread | RE: [xsl] number continuation probl, Andrew Welch |
Re: [xsl] XSLT model not "natural"?, Jonathan Revusky | Date | RE: [xsl] XSLT Recursive Templates, Stevenson Ngila |
Month |