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: remaining problem w/ dyn var scoping, as proposed (and solution?)


>From: Gunther Schadow <gunther@aurora.regenstrief.org>
>Reply-To: xsl-list@lists.mulberrytech.com
>To: xsl-list@lists.mulberrytech.com
>Subject: Re: [xsl] remaining problem w/ dyn var scoping, as proposed (and 
>solution?)
>Date: Thu, 03 Jan 2002 13:28:30 -0500
>
>Matt,
>
>I agree that implicit parameters should be scoped by a namespace
>just like tags should so there would not be conflicts. I'm not
>sure if namespaces should be used for the parameter name or if
>the scope attribute should carry the name of the scope. Actually,
>I personally like your scope attribute more, but wouldn't namespaces
>be more according to common practice?

Of course, the variable names should be QNames.  Then, you could use XML 
Namespaces, instead of (or in addition to) explicitly-named scopes.  IMO, 
the only reasons to use named scopes would be as a way to group variables by 
concern or to modularize a single stylesheet file.  However, I strongly 
believe that interfaces provided by other stylesheet modules should be 
well-specified.  Therefore, I think dynamically-scoped variables should only 
be visible within the file containing the template at the root of their 
scope.

Finally, the variable's visible scope should be bound not only to the 
originating file, but the originating *instance* of the originating file.  
What I mean is that if stylesheet A.xslt imports stylesheet B.xslt, which 
imports stylesheet A.xslt (which I'll take the refer to as A', pardon the 
abuse), a dynamically-scoped variable passed from a template in A to one in 
B, won't be visible in any in A' that B may explicitly call.

This way, separate logical instances, at overlapping levels of the 
call-tree, don't stomp on each other.

BTW, the way you know B is explicitly calling a template in A' would be if 
it provided a namespace for A, when it imported it.  If Bs reference didn't 
have a namespace qualifier, then the template called would actually be in A. 
  This, of course, is only possible if you can supply a namespace for an 
imported module.


>I also like your proposal for requiring implicit parameters to be
>passed on once they are 'caught.' That results in even less dark
>magic happening behind the scene without the explicit agreement
>by the programmer. It would make implicit parameter even more
>closely aligned to explicit parameters.
>
>I don't care if parameter passing is verbose in XSL, everything
>is verbose in XML, so I better get used to that :-) The only
>purpose of implicit parameters is to pass them through templates
>that don't care about them.
>
>Here is an example of all of this:
>
><xsl:template ...>
>   <!-- all implicit parameters used must be declared in the
>        current lexical scope. -->
>   <xsl:param scope='foo' name='text-color' select="'black'"/>
>   <xsl:param scope='foo' name='text-indent' select="''"/>
>   <xsl:param scope='foo' name='text-size' select="10pt"/>
>
>   <out color="{$text-color}"/>
>
>   <xsl:apply-templates ...>
>     <!-- all implicit parameters declared in this lexical
>	 scope must be passed forward explicitly. -->
>     <xsl:with-param scope='foo' name='text-indent'
>                     select="concat($text-indent,'  ')"/>
>     <xsl:with-param scope='foo' name='text-size'
>                     select="$text-size"/>
>   </xsl:apply-templates>
></xsl:template>

Well, just because scope continuation is explicit doesn't mean that it 
requires separate 'with-param's.  It could just as easily be done with a 
special flag added to the 'param' element.


Matt Gruenke


_________________________________________________________________
Chat with friends online, try MSN Messenger: http://messenger.msn.com


 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]