[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Global variable in included stylesheet

Subject: Re: Global variable in included stylesheet
From: "Joerg Heinicke" <joerg.heinicke@xxxxxx>
Date: Thu, 21 Feb 2002 09:03:34 +0100
xml global variable
Hello Andrey,

include means, that every template in 2.xsl is copied to 1.xsl and will be
used there. Your 2.xsl-template can't work as expected, because your global
variable is empty. You only have a local variable declared in the first
template in 1.xsl. You may not handle variables like in Java or other
programming languages. In XSLT it's not possible to reassign a value to
them. If you change your first variable declaration in 1.xsl to
<xsl:variable name="DefaultLanguageID"
select="/global-settings/parameter[@name='DefaultLanguageID']/@value"/>, you
will see the expected output. Now the global variable has the value.

Regards,

Joerg

----- Original Message -----
From: "Andrey Astakhov" <paranorm@xxxxxxxxx>
To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
Sent: Thursday, February 21, 2002 8:02 AM
Subject:  Global variable in included stylesheet


> Hello!
>
> I have xml file (global.xml) and two xsl files (1.xsl, 2.xsl).
> File global.xml is transformed with the stylesheet 1.xsl.
> File 2.xsl is included in 1.xsl.
>
> This files here:
>
> File global.xml
>
> <?xml version="1.0"?>
> <global-settings>
>
> <supporting-languages>
> <language ID="En" caption="English"/>
> <language ID="De" caption="German"/>
> </supporting-languages>
>
> <parameter name="DefaultLanguageID" value="En"/>
> <parameter name="DefaultMenuItemID" value="miCommonInformation"/>
>
> </global-settings>
>
>
> --------------------------------------------------
>
> File 1.xsl
>
> <xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
>
> <xsl:include href="2.xsl"/>
>
> <xsl:variable name="DefaultLanguageID"/>
>
> <xsl:template match="global-settings">
> <xsl:variable name="DefaultLanguageID"
select="parameter[@name='DefaultLanguageID']/@value"/>
>
> <!-- Display variable value in 1.xsl -->
>
> <hr/>
> [1.xsl]: <xsl:value-of select="$DefaultLanguageID"/>
> <hr/>
>
> <xsl:apply-templates select="parameter"/>
>
> </xsl:template>
>
> </xsl:stylesheet>
>
> -----------------------------------------------------
>
> File 2.xsl
>
> <xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
>
> <xsl:template match="parameter">
>
> It is the parameter
>
> <!-- Display variable value in 2.xsl -->
>
> [2.xsl]: <xsl:value-of select="$DefaultLanguageID"/>
> <br/>
> </xsl:template>
>
> </xsl:stylesheet>
>
> ----------------------------------------------------
>
>
>
>
> After the transforming i see:
>
> -----------------
> [1.xsl]: En
> -----------------
> It is the parameter
> [2.xsl]:
> It is the parameter
> [2.xsl]:
>
>
> The problem - i cann't get the value of global variable $DefaultLanguageID
in included stylesheet 2.xsl.
> I thought all global variables must be available anywhere.
>
> Is it wrong?
> How can i obtain $DefaultLanguageID in 2.xsl?
>
> ...and sorry for my poor English...
>
> Best regards,
> Andrey
>
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
>


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.