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]

RE: xsl:include


> One simple thing seems not to work.
> I want to include some variables from an
> extra stylesheet into another stylesheet.
> The one xsl file may look like that:
>
> 'variable.xsl':
> <?xml version="1.0"?>
> <xsl:stylesheet
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; version="1.0">
> <xsl:variable name="var">Something</xsl:variable>
> <xsl:variable name="var1">Something</xsl:variable>
> </xsl:stylesheet>
>
>
> <?xml version="1.0"?>
> <xsl:stylesheet
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; version="1.0">
> <xsl:import href="variable.xsl"/>
>
> <xsl:value-of select="var1"/>
> <xsl:value-of select="var2"/>
>
> </xsl:stylesheet>
>
Once you've impored the stylesheet, you don't need to do anything special to
import its global variables. The second stylesheet can simply refer to $var
and $var1 declared in the first stylesheet. Or, if you want, it can override
them with a global variable declaration, e.g.

<xsl:variable name="var">Something Else</xsl:variable>

In that case a reference to $var (from either stylesheet module) will have
the value "Something Else" rather than "Something".

Mike Kay
Software AG


 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]