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

RE: define a global variable and change it

Subject: RE: define a global variable and change it
From: "W Charlton" <XSLList@xxxxxxxxxx>
Date: Wed, 13 Aug 2008 09:39:56 +0100
RE:  define a global variable and change it
Henry,

It sounds like you can get round your problem by passing parameters into
your stylesheet. How you do this depends on your XML processor.

As the other list members have (nearly) all said can you show us an example.

Try this at home.
XML
<TestXML>TEST</TestXML>

XSL
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<xsl:param name="TestParam">I am a parameter and can be
changed</xsl:param>
	<xsl:variable name="TestVar">I am a variable and can't be
changed</xsl:variable>
	<xsl:template match="/">
		<xsl:text>Test parameter: </xsl:text>
		<xsl:value-of select="$TestParam"/>
		<br/>
		<xsl:text>Test variable: </xsl:text>
		<xsl:value-of select="$TestVar"/>
		<br/>
	</xsl:template>
</xsl:stylesheet>



William Charlton
The yMonda team
yMonda Limited
w: www.ymonda.net

-----Original Message-----
From: henry human [mailto:henry_human@xxxxxxxx]
Sent: 12 August 2008 17:04
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re:  define a global variable and change it

Hi guys, thanks for your answers.

It is such szenario:
User defines a html layout choosing certain html
elements from the menu bar and clik 'ok'.
The XSLT should look after a specific html element
which is a inputfield and contains a string . the
string could be either  section1 or section2. So
far the styleesheet sees the value of the inputfield
(section1or section2) in a xsl:if test .. statement,
it sets/changes the global variable. Other statements
in the stylesheet look for the global variable and do
according to them something and so on.

--- Andrew Welch <andrew.j.welch@xxxxxxxxx> schrieb:

> 2008/8/12 henry human <henry_human@xxxxxxxx>:
> > Hi
> > is it possible to define a global variable with
> xsl?
> > I am going to define such varable to be able
> changing
> > its value some where inside the stylesheet.
> > Hier is asample which does not work!:
> > **********************************
> >    <html>
> >      <body>
> > <xsl:variable name="x" select="'abcd'"/>
> >   <p> Value of x: <xsl:value-of select="$x"/>
> </p>
> > <xsl:variable name="x"> succeded</xsl:variable>
> >   <p> Value of x: <xsl:value-of select="$x"/>
> </p>
> > ************************
>
> You can't change the value of a variable in XSLT -
> they are more like
> constants or Final variables.  There's no need to
> either - show us the
> problem you are trying to solve, and we'll show you
> how to do with
> without needing to change the value of a variable.
>
>
> --
> Andrew Welch
> http://andrewjwelch.com
> Kernow: http://kernowforsaxon.sf.net/
>
>


__________________________________________________
Do You Yahoo!?
Sie sind Spam leid? Yahoo! Mail verf|gt |ber einen herausragenden Schutz
gegen Massenmails.
http://mail.yahoo.com

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.