Not at all sure I understood what your grouping criteria were, but
something like this seems to do something
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:strip-space elements="*"/>
<xsl:template match="document">
<a>
<xsl:apply-templates select="note-block"/>
</a>
</xsl:template>
<xsl:template match="note-block">
<xsl:text> </xsl:text>
<notes>
<xsl:for-each-group
select="../notes/note[(_at_)scope=current()/@scope-id]"
group-adjacent="concat(@merge[.='false']/generate-id(),.)">
<xsl:text> </xsl:text>
<xsl:variable name="p" select="position()"/>
<note ref="{$p}">
<xsl:copy-of select="@* except (@ref,@merge),node()"/>
</note>
<xsl:for-each select="current-group()">
<xsl:text> </xsl:text>
<note-ref xref="{$p}">
<xsl:copy-of select="@* except (@ref,@merge)"/>
</note-ref>
</xsl:for-each>
</xsl:for-each-group>
<xsl:text> </xsl:text>
</notes>
</xsl:template>
</xsl:stylesheet>
$ saxon8 merg.xml merg.xsl
<?xml version="1.0" encoding="UTF-8"?><a>
<notes>
<note ref="1" ID="1" scope="A">Some <b>text</b></note>
<note-ref xref="1" ID="1" scope="A"/>
<note ref="2" ID="2" scope="A">Some <b>text</b></note>
<note-ref xref="2" ID="2" scope="A"/>
<note ref="3" ID="3" scope="A">More</note>
<note-ref xref="3" ID="3" scope="A"/>
<note-ref xref="3" ID="4" scope="A"/>
</notes>
<notes>
<note ref="1" ID="5" scope="B">More</note>
<note-ref xref="1" ID="5" scope="B"/>
<note-ref xref="1" ID="6" scope="B"/>
</notes></a>
________________________________________________________________________
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>
--~--