xsl-list
[Top] [All Lists]

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

2013-08-29 08:10:24
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>

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