[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: alt. to for-each when there's only one

Subject: Re: alt. to for-each when there's only one
From: "Thomas B. Passin" <tpassin@xxxxxxxxxxxx>
Date: Tue, 12 Feb 2002 10:04:39 -0500
alt.to
[alex]

> I've bee using <xsl:for-each select="Orders/RowId">
> to process all the RowId children of my one Orders
> node.
>
> But I've got a case where I know the xml returned
> to me will only contain one RowId child. Is using
> a for-each still the way to go in this case? Or is
> there something more direct and efficient?
>

You usually have a choice between xsl:for-each and xsl:apply-templates for
processing a series of elements.  They aren't fully interchangeable, but
often you can arrange to use one or the other.  There is no harm in using
xsl:for-each when there is only one element to loop over, but more than
likely, xsl:apply-templates will be able to do the job for you.

The prime situation where you want to use xsl:for-each instead of
xsl:apply-templates when there is only one element is when you need to
change the context, as for instance when you want a key to apply to xml
brought in from another source by means of document().

Cheers,

Tom P


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.