On 6 May 2011 10:13, Hermann Stamm-Wilbrandt
<STAMMW(_at_)de(_dot_)ibm(_dot_)com> wrote:
Hello,
I know that this is basic but I cannot get it done correctly.
Input:
<lines>
<line></line>
<line>A1</line>
<line>1</line>
<line>B1</line>
<line></line>
<line>A2</line>
<line>2</line>
<line>2</line>
<line>2</line>
<line>B2</line>
<line></line>
<line></line>
</lines>
Intended output (blockwise, start at A, all including next B):
<line>A1</line>
<line>1</line>
<line>A2</line>
<line>2</line>
<line>2</line>
<line>2</line>
A group-starting-with solution:
<xsl:variable name="a-to-z" select="('a', 'b')"/>
<xsl:template match="/">
<lines>
<xsl:for-each-group select="$input/lines/line[normalize-space(.)]"
group-starting-with="line[lower-case(substring(., 1, 1)) = $a-to-z]">
<xsl:if test="current-group()[2]">
<group>
<xsl:copy-of select="current-group()"/>
</group>
</xsl:if>
</xsl:for-each-group>
</lines>
</xsl:template>
...should be enough to start with.
--
Andrew Welch
http://andrewjwelch.com
--~------------------------------------------------------------------
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>
--~--