[xsl] for-each over sequences of sequences

Subject: [xsl] for-each over sequences of sequences
From: Stefan Krause <stf@xxxxxxxx>
Date: Sun, 01 Mar 2009 13:59:43 +0100
Hello,

I run in an issue with for-each over sequences of sequences:

<xsl:for-each select="(1,2),3">
	<a>
		<xsl:for-each select=".">
			<b><xsl:value-of select="."/></b>
		</xsl:for-each>
	</a>
</xsl:for-each>

returns

<a><b>1</b></a>
<a><b>2</b></a>
<a><b>3</b></a>

and not - as I supposed -

<a><b>1</b><b>2</b></a>
<a><b>3</b></a>

How can I suppress this "flattening" of the original sequence?

The use case is defining a variable with xsl:for-each-group and
iterating over the groups (which consists of sequences of elements):

<xsl:variable name="Chunks" as="node()+">
	<xsl:for-each-group select="//body" group-ending-with="div">
		<xsl:sequence select="current-group()"/>
	</xsl:for-each-group>
</xsl:variable>
<xsl:for-each select="$Chunks">... do something ...</xsl_for-each>
with input

<body>
	<h1>Headline</h1>
	<div> ... </div>
	<div> ... </div>
</body>

I've found a workaround for this issue by wrapping the current-group()
in a <group/>-element, but I was wondering if someone can provide a more
straight-forward solution.

Thanks,

Stefan

Current Thread