[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: newbie--using 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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|