xsl-list
[Top] [All Lists]

Re: [xsl] Numbering new nodes using consecutive integers

2009-03-28 05:35:20
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

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--