Re: [xsl] Re: Assignment no, dynamic scoping si (was: Wishes for XSL revisions ...

Subject: Re: [xsl] Re: Assignment no, dynamic scoping si (was: Wishes for XSL revisions ...
From: terje@xxxxxxxxxxxxxxx (Terje Norderhaug)
Date: Mon, 31 Dec 2001 19:08:01 -0800 (PST)
At 5:34 PM 12/29/01, Gunther Schadow wrote:
>
>So, I don't let it go just yet. The variable construct in XSLT
>is not very useful and dynamic binding as at least an optional
>declareable feature would be a very, very, useful feature that
>I kindly ask to be added to XSLT next revision.
>
>This would be declareable as:
>
><xsl:variable name='foo' select='bar' dynamic='true'/>

I second Gunther's call for variables with dynamic scope. Although it might be better to use an attribute named 'scope' for an eventual declaration though, as in:

 <xsl:variable name='foo' select='bar' scope='dynamic'/>

At 6:24 PM 12/29/01, Dimitre Novatchev wrote:
>
>I am not feeling convinced that the new feature you're proposing is necessary or
>useful at all. As other people pointed out, you have yet to provide a precise
>example where using this feature will help produce a better solution or a solution,
>which was not possible without the feature you propose.

Being able to simplify the stylesheet by removing repeated parameter passing is reason enough for me. However, I have also missed variables with dynamic scope when extending predefined stylesheets.  

Dynamic scoped variables may reduce the redundancy between imported and importing stylesheets, with associated benefits. It makes imported/importing stylesheets less dependent on each other by allowing passing of values between templates in a stylesheet without demands on the templates in the other stylesheet.

Say you have a stylesheet "book.xsl" containing templates to process the various element types in a book (e.g. book, chapter, paragraph, ...) where each template applies templates recursively, like this:

<xsl:template match="chapter">
  <fo:block>
    <xsl:apply-templates/>
  </fo:block>
</xsl:template>

Consider the case that you need to make a stylesheet that imports a third party "book.xsl" then overrides its templates for 'book' and 'paragraph' elements with custom processing but with a minimum of duplication. For some reason, you would like to pass a parameter from the 'book' template to the 'paragraph' template. 

Unfortunately, today this requires that you duplicate and modify the 'chapter' template (and possibly others) from the "book.xsl" stylesheet to pass along the parameter. You end up with a stylesheet that contains most or all of the imported stylesheet.

With support for dynamic scope, the 'book' template would be able to bind variables that are visible for the 'paragraph' template without requiring modifications of other templates in "book.xsl".

-- 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