This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Re: Assignment no, dynamic scoping si


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@in-progress.com> | 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]