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

RE: newbie question

Subject: RE: newbie question
From: "Allan Jones" <allan.jones@xxxxxxxxxxxx>
Date: Tue, 29 Oct 2002 12:47:37 -0000
get_variable xsl
|Thanks for UR reply. That clears my doubts.
|But what if U have too many variables in UR page?? Ex: for a
|registration form.
|Is there any way I can escape filling my page with when-otherwise
|statements (one for each variable)??

it depends on what you mean.  if you're talking about creating one variable
that has the same value all throughout the entire stylesheet, then you can
create a global variable at the top of the page (i.e. before you declare any
templates) and use that variable throughout your stylesheet.  the syntax is
exactly the same as with the previous one, but as you're using a relative
xpath that might not be what you're looking for.

another option could be to use a template to provide the necessary value.
something along these lines might be what you're looking for:

(in your template):

<xsl:variable name="uContact>
	<xsl:apply-templates select="." mode="get_variable" />
</xsl:variable>

(as a template in your stylesheet):

<xsl:template match="*" mode="get_variable">
	<xsl:variable name="uContact">
		<xsl:choose>
			<xsl:when test="//request/param[@name='action']='Edit'">
				<xsl:value-of select="./selection/email" />
			</xsl:when>
			<xsl:when ... />
			<xsl:otherwise>
				<xsl:value-of select="//request/param[@name='email']" />
			</xsl:otherwise>
		</xsl:choose>
	</xsl:variable>
	<xsl:value-of select="$uContact" />
</xsl:template>

this would effectively call the above template which would populate the
variable "uContact" according to your choose statement, and then pass back
this value to the template that called it.  i've not tested that code,
although i've used similar code in my own templates.

is that more what you were looking for?

b


 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.