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

RE: xsl:for-each immediately followed by xsl:if

Subject: RE: xsl:for-each immediately followed by xsl:if
From: "Michael Kay" <michael.h.kay@xxxxxxxxxxxx>
Date: Fri, 1 Feb 2002 15:14:28 -0000
xsl for each if
> The faq says not to immediately follow an xsl:for-each with
> an xsl:if.  How
> do I merge these into one statement?

You can replace

<xsl:for-each select="EEE">
  <xsl:if test="TTT">
    SSS
  </xsl:if>
</xsl:for-each>

by

<xsl:for-each select="EEE[TTT]">
    SSS
</xsl:for-each>


>
> Another newbie question - can I depend on the order of the tags and
> attributes being delivered to my stylesheet in the same order
> as they were
> listed in the XML file?  So a for-each runs through the entries in a
> deterministic order or do I always have to sort first?

Let's be cruel to be kind: tags are never delivered to your stylesheet. Only
nodes are. A start tag and an end tag are combined by the XML parser to
create an element node, and the element node is processed by the stylesheet
as a single unit. It's really important to understand this.

Yes, <xsl:for-each>, in the absence of an <xsl:sort>, processes the nodes in
document order, which is deterministic so long as the nodes all come from
the same document. (Technically, it could process the nodes in parallel or
in reverse order, but the effect is *as if* they were processed in this
order, which is what you're interested in).

Michael Kay
Software AG
home: Michael.H.Kay@xxxxxxxxxxxx
work: Michael.Kay@xxxxxxxxxxxxxx >
>


 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.