Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

IMAGE TAG NOT WORKING

Status
Not open for further replies.

thunderain

Programmer
Jan 10, 2002
40
CA
I am working on my first major xml project. I have everything working pretty well working
except putting an image in. I have tried many different things, but here is what i have now.
I cannot get the image to appear except as hardcoded below.

Here is what I have in my XML:

<images>
<img src=&quot;xxx.jpg&quot;/>
</images>

(this is inside songsite and song tags)

Here is what I have in my XSL:

<P/><xsl:value-of select=&quot;/songsite/song/images&quot;/>
<img>
<xsl:attribute name=&quot;src&quot;>
<xsl:value-of select=&quot;@src&quot; />
</xsl:attribute>
</img>

If i hardcode my jpg file into the xsl code on the third line, as below, the image pops up.

<xsl:attribute name=&quot;src&quot;>xxx.jpg

But i can't do this, I need to send it from the xml sheet

Can anyone help me

thank you
thunderain
 
Instead of using <img> tags I believe you will need to allow the xsl to create the element for you. Try this:
Code:
<xsl:element value=&quot;img&quot;>
   <xsl:attribute name=&quot;src&quot;><xsl:value-of select=&quot;@src&quot; /></xsl:attribute>
</xsl:element>
The reason I killed the extra whitespace in the attribute nis that I have noticed if you leave it in when building hrefs, it actuially tries to leave it in your transoformed html, giving you href's with a great deal of whitespace that some browser dislike.
Hope that helps,
-Tarwn ------------ My Little Dictionary ---------
Reverse Engineering - The expensive solution to not paying for proper documentation
 

Sorry about taking so long to get back to this, but your answer helped out, but with some modifications, i put in the path in the value-of select and it worked.

<xsl:element name=&quot;img&quot;>
<xsl:attribute name=&quot;src&quot;><xsl:value-of select=&quot;/songsite/song/albumimage/img/@src&quot; /></xsl:attribute>
<xsl:attribute name=&quot;alt&quot;><xsl:value-of select=&quot;/songsite/song/albumimage/img/@alt&quot; /></xsl:attribute>
</xsl:element>

Thanx
thunderain
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top