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

Re: Numbering new nodes using consecutive integers

Subject: Re: Numbering new nodes using consecutive integers
From: Michael Ludwig <milu71@xxxxxx>
Date: Sat, 28 Mar 2009 10:34:38 +0100
Re:  Numbering new nodes using consecutive integers
David Carlisle schrieb am 27.03.2009 um 21:58:30 (+0000):
> 
> perhaps this is less wrong.

> <xsl:template match="Groups">
>   <xsl:copy>
>     <xsl:apply-templates
>       select="G1/M[ position() mod $M-per-G2 = 1 ]" mode="group"/>
>   </xsl:copy>
> </xsl:template>
>
> <xsl:template match="M" mode="group">
>   <G2 no="{position()}"><!-- I want this GR to be numbered sequentially. -->
>     <xsl:copy-of select="
>       . | following-sibling::M[position() &lt; $M-per-G2]"/>
>   </G2>
> </xsl:template>

Simply perfect. Thanks!

The lesson might be: Knowing that position() will be the device to do
the numbering (and not <xsl:number/>), the task is in setting up a
suitable current context, which implies the required numbering.

This context happily (and necessarily, in this case) coincides with what
I need to introduce a new hiararchical level <G2>.

By applying templates from <G1>, I had moved too close to the problem
and lost the occasion to solve it easily. Thanks for reframing this!

Michael Ludwig

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.