Yes in the end, I ended up using global parameter values that are passed by
development it is lacking in areas that are common for other languages. I
will be addressed by the w3c organization. Until then there are always work
"Kathleen Dollard" <Kathleen@mvps.org> wrote in message
news:e5XgKq9yDHA.1684@TK2MSFTNGP12.phx.gbl...
> Keith,
>
> Sorrry to be late, but I was perusing here looking for something else and
> saw this.
>
> I definitely agree with you that duplicating selection information is a
bad
> idea. I have not read this whole thread, so wondered if you had considered
> using global variables for these values. I find these extremely useful.
> While the idea of "global variables" has negative connotations in some
> languages, in XSLT, this is more or less the same as a module level
variable
> and has all of the same benefits.
>
> Kathleen
>
> "Keith Chadwick" <chady@magma.ca> wrote in message
> news:GbSdnc68rNcotU-i4p2dnA@magma.ca...
> > Ok then what if I have 10 variables/params that ALL need to be passed to
> > each sub template?
> >
> > The reason for this is that the user creates document definitions via a
> > wizard. The wizard offers up a bunch of options on how to format
certain
> > sets of data. I could create a template for each possible combination
of
> > options but there would be far to much duplicated code to manage. The
> > property 'style' which is loaded into a param dictates the overall
layout
> > format. The other properties dictate some sub formatting, like place
> option
> > controls on right or left. So what I have is:
> >
> > <xsl:template select="//object">
> > <xsl:param name="style" select="metrics/render/@style"/>
> >
> > <!-- sub-formatting properties -->
> > <xsl:param name="controllayout"
> select="metrics/render/@controllayout"/>
> > ... ten more params here that dictate the formatting style
> >
> > <xsl:choose>
> > <xsl:when test="@style=1">
> > <xsl:call-template name="LINEITEM_GRID"/>
> > </xsl:when>
> > <xsl:when test="@style="2">
> > <xsl:call-template name="LINEITEM_BLOCK"/>
> > </xsl:when>
> > ... more when test
> > </xsl:choose>
> > </xsl:template>
> >
> >
> > In the section sub-formatting properties there are currently 10 params
and
> > there will be more as the wizard development progresses. Now since each
> > child template runs in the same node as caller I can simply move the
> > definition of each of the sub-formatting param into each of the
> > call-template templates. I know what the solution is, but my issue is
> that
> > in this particular circumstance I am duplicating each of those params or
> > variables in each child template. This in its self is not the issue and
> of
> > course works fine. My issue is that I end up with a fair amount of
> > duplicated code, approx 80 lines (10 params * 8 styles). I hate copying
> and
> > pasting code like that it lacks elegance and becomes inherently more
> > difficult to maintain. From my point of view a param defined in a
> template
> > should be automatically accessible to the template called within the
that
> > template. Since the call-template runs in the context of the current
node
> > why should it not also exist in the context of params or variable also
> > defined during that node iteration? Now I realize that in my above
> example
> > the values assigned to the params are available in each child template
> > because they belong to the same node set so perhaps this is not the best
> > example but do you get my drift?
> >
> > I love the functionality of XSLT it solves a lot of problems that exist
in
> > web developments but like any language I find it lacking in some
regards.
> > But if we don't bring stuff like this up the language never grows. It
is
> > like CSS, I have been asking for years for a RADIUS attribute on borders
> > allowing for rounded border corners.
> >
> > Cheers
> > Keith
> >
> > "Dimitre Novatchev" <dimitren@altavista.com> wrote in message
> > news:uYXSFOCvDHA.2448@TK2MSFTNGP12.phx.gbl...
> > >
> > > "Keith Chadwick" <kchadwick@leewardsystems.com> wrote in message
> > > news:uBOnC5AvDHA.2880@tk2msftngp13.phx.gbl...
> > > > I knew that would be your answer and still the same issue but twice
as
> > > much.
> > > > Now I am defining them in the parent template, in the with-param for
> > each
> > > > template I call.
> > > >
> > > > I realize how it works and what I am stating is that the language
> lacks
> > > > elegance in this area. It would be nice to be able to say:
> > > >
> > > > <xsl:param name="myvar" scope="[template][stylesheet]" value=""/>
> > > >
> > > > A param defined outside of a template would automatically have a
scope
> > of
> > > > template but inside a template you could override it and state
> > stylesheet
> > > > thereby making "available" to any template in the style sheet. I
can
> > > think
> > > > of a lot implementations where it would be nice to have a document
> > > fragment
> > > > placed in the param based on the templates processing and then be
> > > available
> > > > to any other template in the transformation.
> > >
> > > This is perfectly possible to do without the constructs you propose
> above:
> > >
> > > <xsl:variable name="vrtfVar">
> > > <xsl:apply-templates/>
> > > </xsl:variable>
> > >
> > > <xsl:apply-templates select="someExpression">
> > > <xsl:with-param name="somepName"
> > select="msxsl:node-set($vrtfVar)/node"/>
> > > </xsl:apply-templates>
> > >
> > >
> > > The visibility rules for an xsl:param or xsl:variable are not
different
> > than
> > > in most block-structured programming languages: an xsl:variable
defined
> in
> > > an outer block is visible after its definition in the same block or in
> any
> > > nested blocks, following the definition of the variable (exactly the
> same
> > > about xsl:param). An xsl:variable defined in an inner block is not
> visible
> > > (and in fact does not exist) outside of that block.
> > >
> > >
> > >
> > > =====
> > > Cheers,
> > >
> > > Dimitre Novatchev.
> > >
http://fxsl.sourceforge.net/ -- the home of FXSL
> > >
> > >
> > >
> > >
> >
> >
>
>