--- 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[(_at_)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[(_at_)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[(_at_)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