[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Globals in xsl:script
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 shouldn't use. 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 for eval. 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'][0] to have the same result as the 1st match. Optimizations are possible, that is. Any thoughts? Bill __________________________________________________ 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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|