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

: Setting the value of variables, conditionally.

Subject: : Setting the value of variables, conditionally.
From: Aparna Joshi <aparna.joshi@xxxxxxxxxx>
Date: Fri, 13 Jul 2001 08:46:29 -0700
xsl conditionally setting variables
Hi All, 

Here is the flow of what I have to do. I want to know if its possible using
stylesheet variables.


<xsl:stylesheet version='1.0'
xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>

<xsl:variable name="globalVar1">DEFAULTVAL1</xsl:variable>
<xsl:variable name="globalVar2">DEFAULTVAL2</xsl:variable>

<xsl:template match="parent">
<!-- compute and assign value to the variables declared above-->
	<xsl:choose>
		<xsl:when test="count(element1)>0">
			set globalVar1="CONDVAL11"
			set globalVar2="CONDVAL12"
		</xsl:when>
		<xsl:when test="count(element2)>0">
			set globalVar1="CONDVAL21"
			set globalVar2="CONDVAL22"
		</xsl:when>		
	<xsl:choose>	

<!-- Display the variables in the HTML page -->
<html>
	<head>
		<title>
			<xsl:value-of select="$globalVar1" />
		</title>
	</head>
	<body>
		<b>
			<xsl:value-of select="$globalVar2" />
		</b>
	</body>
</html>
</xsl:template>
</xsl:stylesheet>


The xml structure could be...
<parent>
	<element1> ... </element1>
	<element2> ... </element2>
</parent>

So, in the <html> </html> portion the globalVar1 and globaVar2 should show
CONDVALxx   value.    Also, the aim is to keep the number of <xsl:when...>
less and to have a generic <html> </html> code.


Thanks in advance for any help/suggestion.

Aparna


 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.