Subject: RE: [xsl] xsl:for-each immediately followed by xsl:if From: "Michael Kay" <michael.h.kay@xxxxxxxxxxxx> Date: Fri, 1 Feb 2002 15:14:28 -0000 |
> 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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] xsl:for-each immediately foll, Mike Bandy | Thread | RE: [xsl] xsl:for-each immediately , Stuart Celarier |
Re: [xsl] Enumerating template matc, Morten | Date | Re: [xsl] Choosing different output, Alvaro Mujica |
Month |