[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Re: Assignment no, dynamic scoping si

Subject: Re: Re: Assignment no, dynamic scoping si
From: terje@xxxxxxxxxxxxxxx (Terje Norderhaug)
Date: Sun, 6 Jan 2002 15:31:49 -0800 (PST)
advantages of dynamic scoping
At 7:42 PM 1/6/02, Mark Nahabedian wrote:
>Assuming the use of the XSLT "push" model, the dynamic state of the
>processing is dictated by the static content of the input document.
>Since the language makes no promises about the order in which sibling
>(co-selected) nodes are processed, to achieve consistent results,
>dynamic state could only be communicated downward, not across
>siblings, which are processed "in parallel".  Thus, any data that
>could be communicated through dynamic scoping could also be extracted
>via the ancestor axis.  

Dynamic variables in the form of implicit parameters provides the same functionality as explicit parameters but without the need for manually passing on the parameters. If  any data that can be communicated through dynamic scoping also can be extracted via the ancestor axis, it would follow that explicit parameters are superflucious. 

Obviously this is not the case as is evident for example when an xsl:apply-templates selects nodes outside the descendant of the current node. Another case is when a template contains two xsl:apply-templates called with different values for the same parameter. This demonstrates that extracting values via the ancestor axis cannot in general replace explcit nor implicit parameters.

Everything that can be done with implicit parameters can be done with explicit parameters, and vice versa. However, implicit parameters (as dynamic variables in general) can eliminate much of the need for duplicating templates from an imported to an importing stylesheet in cases where parameter passing is desired beyond one template. The benefits associated with eliminating such redundancy should be well known. 

>Dynamic scoping would thus only provide a
>benefit if there was some complicated, expensive or redundant
>calculation to be economised on either in execution time, clarity or
>code space.

Although this is in itself a valuable advantage, it is not the only one.

>Rather than dynamic scoping, One could instead imagine a mechanism
>that would allow one to look at the ancestors of the already computed
>higher up levels of the result tree to achieve a similar affect.  One
>would want a means to supress serialization of such data that was only
>used for further computation and was not required in the output.

Actually, dynamic variables provides such a mechanism without requiring complex navigation in the result tree. Dynamic variables are bound for the scope of generating the rest of the current result node. In other words, the scope of dynamic variables follows the structure of the result tree, while the scope of static variables follows the structure of the source document. 

This means that dynamic variables can be used to affect generation of descendants and following siblings. For example, you can make the template for list items generate different markup depending on whether it will be placed in an html:table or an html:ul. Achieving the same using the ancestor axis in conditional expressions quickly becomes complex or impossible when you go beyond simple cases, particularly if you want to minimize dependence on the document type and imported stylesheets.

-- Terje <terje@xxxxxxxxxxxxxxx> | Media Design in*Progress 
   Software for Mac Web Professionals at <http://www.in-progress.com>
   Take Advantage of Server Side XML and XSL with Interaction 3.6!

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

Current Thread


Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
First Name
Last Name
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.