[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
[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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|