Thanks already for this tip, but I'm not able to get it running. I've been checking the web for some examples on using grouping (I'm fairly new to xslt 2.0 to be honnest), but all examples expect nice, clean structured input. not real live data...
What I tried is the following : make a simple xml file containing some examples of the various ways the underline tags are provided.
xml sample :
<TestFile>
<!-- Para tag containing no underline tags -->
<Para>
<Content>[text_not_underlined]</Content>
</Para>
<!-- correct encapsulation from source -->
<Para>
<Content>
<Underline/>[text_to_be_underlined]<EndUnderline/>
<p>Some test data</p>
</Content>
</Para>
<!-- extra underline tag that should be ignored -->
<Para>
<Content>
<Underline/>[text_to_be_underlined]<Underline/>
<EndUnderline/>
<p>Some other test data</p>
</Content>
</Para>
<!-- some extra end underline tags that should be ignored -->
<Para>
<Content>
<EndUnderline/>[no_longer_underline]<EndUnderline/>
<p>: More data</p>
</Content>
</Para>
</TestFile>
When using your group coding in a template results are not exactly what I expected, so I'm probably overlooking something. I.ve tried various things, but neither one of these were successful. Could you therefore look at below, and point me to what I do wrong ? I manage indeed to encapsulate my underlined content in a u tag, but the rest of the content is gone
-----------------------
Stylesheet
-----------------------
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="Content">
<xsl:copy>
<xsl:copy-of select="@*"/>
<xsl:for-each-group select="node()" group-ending-with="EndUnderline">
<xsl:variable name="start" select="current-group()[self::Underline][1]"/>
<xsl:copy-of select="current-group()[$start >> .]"/>
<u>
<xsl:copy-of select="current-group()[. >> $start][not(self::Underline)][not(self::EndUnderline)]"/>
</u>
</xsl:for-each-group>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
-----------------------
Current result

-----------------------
<TestFile>
<!-- Para tag containing no underline tags -->
<Para>
<Content>
<u/>
</Content>
</Para>
<!-- correct encapsulation from source -->
<Para>
<Content>
<u>[text_to_be_underlined]</u>
<u/>
</Content>
</Para>
<!-- extra underline tag that should be ignored -->
<Para>
<Content>
<u>[text_to_be_underlined]</u>
<u/>
</Content>
</Para>
<!-- some extra end underline tags that should be ignored -->
<Para>
<Content>
<u/>
<u/>
</Content>
</Para>
</TestFile>
-----------------------
Hoped for result
-----------------------
<TestFile>
<!-- Para tag containing no underline tags -->
<Para>
<Content>[text_not_underlined]</Content>
</Para>
<!-- correct encapsulation from source -->
<Para>
<Content>
<u>[text_to_be_underlined]</u>
<p>Some test data</p>
</Content>
</Para>
<!-- extra underline tag that should be ignored -->
<Para>
<Content>
<u>[text_to_be_underlined]</u>
<p>Some other test data</p>
</Content>
</Para>
<!-- some extra end underline tags that should be ignored -->
<Para>
<Content>
[no_longer_underline]
<p>: More data</p>
</Content>
</Para>
</TestFile>
Since the actual XML file is pretty large and containing a lot more data and variety of tags, I assume some way of working with the identity template needs to be done, but I can't figure out how to make it work together with the group template. If it might make things easier ; all content to be underlined resides within a <Content> tag, but lot more additional tags as shown in the example can be underneeth the <Content> tag.
Thanks again for any support on this !