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

Re: newbie--using variables

Subject: Re: newbie--using variables
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Tue, 22 Jan 2002 16:45:27 +0000
logo variables
Hi Jitt,

> I'm trying to display an image and for the source, I'd like to use a
> variable because the path to the image will change from time to time.  
> Is something like this possible?  If not, can anyone suggest another 
> way?  Here is an example:
>
> I declare my variable on top and use it down below:
>
> <xsl:variable name="logo"> 
>         <xsl:choose> 
>                 <xsl:when test="//xsl_logo='Y'">
>                         <img height="40" 
> src="\\csmpls18m\data\application\images\nsslogoblue.gif" 
> width="120"></img>
>                 </xsl:when> 
>         </xsl:choose> 
> </xsl:variable> 
>
> <td valign="top"><xsl:value-of select="$logo"/>

Sure, that's fine. The only problem that you'll find is that if you
get the *value* of the $logo variable, you'll end up with nothing,
because the img element that you create is an empty element and
therefore has no string value. You should instead use the xsl:copy-of
element to create a *copy* of the content of the $logo variable:

  <xsl:copy-of select="$logo" />

And that will insert the img element in your document.

(By the way, having a single xsl:when inside an xsl:choose is exactly
the same (but longer!) as having an xsl:if.)

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/


 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.