[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

[xsl] [XSLT Streaming] Are xsl:for-each and xsl:iterate equivalent?


Subject: [xsl] [XSLT Streaming] Are xsl:for-each and xsl:iterate equivalent?
From: "Costello, Roger L." <costello@xxxxxxxxx>
Date: Thu, 29 Aug 2013 13:10:06 +0000

Hi Folks,

I realize that xsl:iterate has some capabilities that xsl:for-each doesn't
have, such as the ability to break out of the loop before processing the
entire sequence.

But leaving that aside, they are both ways of looping over a sequence of
items, right? And both can be used with streaming, right?

Is xsl:iterate the preferred loop mechanism when doing streaming?

The following are equivalent, right? Is one preferred over the other?

-----------------------------------------------------
    Loop using xsl:iterate
-----------------------------------------------------
    <xsl:template match="BookCatalogue" mode="streaming">
        <Books>
            <xsl:iterate select="Book">
                <Book>
                    <Title><xsl:value-of select="Title" /></Title>
                    <Author><xsl:value-of select="Author" /></Author>
                </Book>
            </xsl:iterate>
        </Books>
    </xsl:template>

-----------------------------------------------------
    Loop using xsl:for-each
-----------------------------------------------------
    <xsl:template match="BookCatalogue" mode="streaming">
        <Books>
            <xsl:for-each select="Book">
                <Book>
                    <Title><xsl:value-of select="Title" /></Title>
                    <Author><xsl:value-of select="Author" /></Author>
                </Book>
            </xsl:for-each>
        </Books>
    </xsl:template>


Current Thread