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: variable definition reuse


>
> <xsl:template match="//programme">
> <!-- VARIABLE DECLARATION -->
> <xsl:variable name = "color" select = "color">
> <xsl:variable name = "weight" select = "weight">
> <xsl:variable name = "cost" select = "cost">
> <xsl:variable name = "acceptance" select = "acceptance">
> <xsl:variable name = "mnf-date" select = "mnf-date">
> <xsl:variable name = "exp-date" select = "exp-date">
> <xsl:variable name = "lable-design" select = "lable-design">
> <xsl:variable name = "mkt-agncy" select = "mkt-agncy">
> <xsl:variable name = "serial-id" select = "serial-id">
> <xsl:variable name = "order-qty" select = "order-qty">
> <xsl:variable name = "re-order-level" select = "re-order-level">
> .<!-- VARIABLE DECLARATION ENDS -->
> .
> .-----   do some formating on these variables and display

> This block IS
> THE ONLY THING THAT CHANGES IN ALL THE 20 FILES )  ----------
> .
> </xsl:template>
> This block remains same in all the 20 files. Now what i
> wanted to do is that
> define these variables in a separate file so that all the 20
> XSL files can
> access/share these variables.

The only variables you can share across XSLT stylesheet modules are global
variables. Global variables have a single value that is constant for the
whole transformation. The variables above have a different value each time
the template rule is instantiated, because they are defined relatively to
the <programme> element.

As David pointed out, there is very little point defining these variables.
All it does is enable you to write $exp-date instead of exp-date, which
gives you neither an improvement in stylesheet legibility nor an improvement
in performance.

Michael Kay
Software AG
home: Michael.H.Kay@ntlworld.com
work: Michael.Kay@softwareag.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]