[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
[xsl] Relying on the orser of excution is harmful (Was: Re: XSL Help!!)
Subject: [xsl] Relying on the orser of excution is harmful (Was: Re: XSL Help!!) From: Dimitre Novatchev <dnovatchev@xxxxxxxxx> Date: Thu, 5 Dec 2002 22:22:54 -0800 (PST) |
--- Chandra wrote: > Hi there, > I have a couple of questions on XSL stylesheets. > 1)<xsl:template match="MEMBER"> > <xsl:apply-templates select="NAME"/> > <xsl:apply-templates select="Phone[@type='work']"/> > </xsl:template> > > When u say <xsl:apply-templates select="NAME"/>, Will all the NAME > nodes > under MEMBER be selected(say there are more than 1 NAME nodes under > MEMBER)?Also will the NAME template rule be applied to each one of > the > NAME > nodes before the Phone node is selected? Having these two instructions in that order: > <xsl:apply-templates select="NAME"/> > <xsl:apply-templates select="Phone[@type='work']"/> does not guarantee at all that the appropriate templates will be applied on the "NAME" children before the appropriate templates will be applied on the "Phone[@type='work']" children. They may be applied in any order or in parallel and this is one of the reasons why relying on the order of calling extension functions often produces unpredictable results. The only guarantee is that when the output tree is constructed, the output of the first xsl instruction will precede the output of the second. However, this doesn't at all affect the many different possible ways how these will be executed in the course of time. The XSLT spec explains the processing model first sequentially and then says: "Implementations are free to process the source document in any way that produces the same result as if it were processed using this processing model." http://www.w3.org/TR/xslt#section-Processing-Model A good example that one must not rely on "order of execution" can be found here: http://groups.google.com/groups?hl=de&frame=right&th=418985883ecc2e2c&seekm=uZk9iKYiBHA.2000%40tkmsftngp04#link1 This touches another topic -- the harm of uncontrolled use of extension functions (with side effects) in a functional programming language. There are ways to control the order of execution, but placing two xsl instructions one after the other is not one of these ways. ===== Cheers, Dimitre Novatchev. http://fxsl.sourceforge.net/ -- the home of FXSL __________________________________________________ Do you Yahoo!? Yahoo! Mail Plus - Powerful. Affordable. Sign up now. http://mailplus.yahoo.com XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Peculiar Problem in .xsl , Mike Brown | Thread | Re: [xsl] Relying on the orser of e, Gunther Schadow |
[xsl] Peculiar Problem in .xsl file, Chandra - | Date | Re: [xsl] Peculiar Problem in .xsl , Mike Brown |
Month |