[XSL-LIST Mailing List Archive Home]
Globals in xsl:script
Subject: Globals in xsl:script|
From: Bill Martschenko <billmartschenko@xxxxxxxxx>
Date: Wed, 29 Sep 1999 00:14:53 -0700 (PDT)
I have a concern about globals in xsl:script. Any
thoughts would be appreciated.
XSL specifies what and not how. For example, by
specifying sort order, the only requirement is that
the final output is sorted. The order in which nodes
actually have templates applied to them is not
specified. I can imagine a sophisticated enough XSL
where the compiler would translate into dependency
graphs and use a topological order for eval.
In the sorting example, it is perfectly compliant for
the nodes to be evaluted in document order, the XSL
engine to collect all results, and then sort the
results *after* all templates have been instantiated.
Why is this important? If templates call xsl:script
definitions and these definitions use globals, then
how is a script writer assured anything about the
sequence in which the script will be called.
Scripts that are strictly functions by the comp sci
definition have no side effects and hence don't care.
Those with globals do.
MS has a sample on MSDN showing a 'totals' calculation
including intermediate sub-totals. I think this
relies on implementation details the script writer
In fact, this specification of what and not how is
what functional programming languages like Sugar and
ML were all about. Compiler can choose the best order
I've posted a sample that used some functions with
zero side effects. The functions look expensive, but
like functional programming languages, the compiler
can also rely on a 2nd pattern match of
"(//CATEGORY)[.='Category A'] to have the same
result as the 1st match. Optimizations are possible,
Do You Yahoo!?
Bid and sell for free at http://auctions.yahoo.com
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list