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

Re: number continuation problem

Subject: Re: number continuation problem
From: David Carlisle <davidc@xxxxxxxxx>
Date: Fri, 27 Jun 2003 10:20:35 +0100
continuous decimal
<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)&gt;count(following-sibling::*[1][self::else]/node)]/node) +
count(parent::else/preceding-sibling::if[position()&gt;1][count(node)&gt;count(following-sibling::*[1][self::else]/node)]/node) +
count(../preceding-sibling::else[count(node)&gt;=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

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.