grr your test document had two L2.1 sections which caused me some grief
trying to work out why it numbered the second one 2.2;-)
If I understand what you want, something like this:
<xsl:template match="book" name="book">
<xsl:param name="n" select="1"/>
<xsl:param name="prefix" select="''"/>
<xsl:param name="nodes" select="*"/>
<xsl:param name="offset" select="0"/>
<xsl:for-each-group select="$nodes"
group-starting-with="title[(_at_)role=$n]">
<xsl:choose>
<xsl:when test="empty($nodes)">
</xsl:when>
<xsl:when test="self::title[(_at_)role=$n]">
<block role="{(_at_)role}" number="{$prefix}{position()-$offset}">
<xsl:call-template name="book">
<xsl:with-param name="n" select="$n+1"/>
<xsl:with-param name="nodes" select="current-group()"/>
<xsl:with-param name="prefix"
select="concat($prefix,position()-$offset,'.')"/>
<xsl:with-param name="offset" select="1"/>
</xsl:call-template>
</block>
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="current-group()"/>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each-group>
</xsl:template>
</xsl:stylesheet>
$ saxon9 dpbook.xml dpbook.xsl
<?xml version="1.0" encoding="UTF-8"?>
<block role="1" number="1">
<title role="1">L1</title>
<block role="2" number="1.1">
<title role="2">L1.1</title>
<para>This document defines an XML schema for ....</para>
</block>
<block role="2" number="1.2">
<title role="2">L1.2</title>
<para>The normative XML Schema for the OpenDoc ....</para>
</block>
</block>
<block role="1" number="2">
<title role="1">L2</title>
<para>This chapter introduces the structure of ....</para>
<para>In the OpenDocument format, each structu ....</para>
<block role="2" number="2.1">
<title role="2">L2.1</title>
<para>A document root element is the primary e ....</para>
<block role="3" number="2.1.1">
<title role="3">L2.1.1</title>
<para>The content models of the five root elem ....</para>
<block role="4" number="2.1.1.1">
<title role="4">L4 test</title>
<para>The content models of the five root elem ....</para>
<para>The <office:document> root contains a co ....</para>
</block>
<block role="4" number="2.1.1.2">
<title role="4">L4 test 2.1.1.2</title>
<para>The content models of the five root elem ....</para>
<para>The <office:document> root contains a co ....</para>
</block>
</block>
</block>
<block role="2" number="2.2">
<title role="2">L2.1</title>
<para>A document root element is the primary e ....</para>
</block>
</block>
________________________________________________________________________
The Numerical Algorithms Group Ltd is a company registered in England
and Wales with company number 1249803. The registered office is:
Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom.
This e-mail has been scanned for all viruses by Star. The service is
powered by MessageLabs.
________________________________________________________________________
--~------------------------------------------------------------------
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>
--~--