XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Show tree view Topic
Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
Mary JohnsonSubject: .JPG Filename Initialization in XSLT from XML tag
Author: Mary Johnson
Date: 10 Nov 2005 07:19 PM
I am embarrased to say that I spent over 8 hours on the Internet today researching this topic and I am crying "Uncle!". Please, someone tell me if it is even possible to do what I want to do.

In my XSLT, I want to display a .jpg image whose filename is specified in an XML file.

I don't know the syntax for inserting the tag reference within the
<img src="xxxxxxxxxx"> HTML code.

I have tried the obvious (to me) following options, to no avail:

<img src="{PictureID}" />
<img src="{$PictureID}" />
<img src="<xsl:value-of select="PictureID">" />
<img src="&lt;xsl:value-of select="PictureID"&gt:" />

Postnext
Ivan PedruzziSubject: .JPG Filename Initialization in XSLT from XML tag
Author: Ivan Pedruzzi
Date: 10 Nov 2005 08:57 PM
Mary,

Could you post a sample of your XML input document?

Ivan Pedruzzi
Stylus Studio Team

Postnext
Minollo I.Subject: .JPG Filename Initialization in XSLT from XML tag
Author: Minollo I.
Date: 10 Nov 2005 08:59 PM
What is PictureID? An element? An attribute? A variable/parameter?
And what is the XSLT context in which that output is created?

The syntax you are trying to use is an attribute template; assuming that this outputs the value you want:
<xsl:value-of select="PictureID"/>
...then this one would create the src attribute you are looking for:
<img src="{PictureID}"/>

What you type in between "{}" is resolved as an XPath expression... but I'm missing the answers to the questions above to be able to understand if the XPath expression "PictureID" is what is needed in your specific context.

Minollo

Posttop
Mary JohnsonSubject: .JPG Filename Initialization in XSLT from XML tag
Author: Mary Johnson
Date: 11 Nov 2005 09:04 AM
Thank you, everyone. Your responses gave me encouragement that it was possible and focused me to look more carefully at the XML and try another option and it is now working.

My problem was that I didn't understand that I had to fully qualify my path to my XML tag. I thought that I could just use the final element name. See below:

DID NOT WORK:

<img src="{PictureID}" />

DID WORK:

<img src="{ResidentialProperty/Listing/Picture/PictureID}" />

Thank you again!

 
Go to previous topicPrev TopicGo to next topicNext Topic
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.