This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
RE: xsl:include
- To: <xsl-list at lists dot mulberrytech dot com>
- Subject: RE: [xsl] xsl:include
- From: "Michael Kay" <mhkay at iclway dot co dot uk>
- Date: Tue, 27 Mar 2001 10:49:55 +0100
- Reply-To: xsl-list at lists dot mulberrytech dot com
> 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