xsl-list
[Top] [All Lists]

[xsl] for-each over sequences of sequences

2009-03-01 07:48:57
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

--~------------------------------------------------------------------
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>
--~--

<Prev in Thread] Current Thread [Next in Thread>