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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Images with XSL - IE & Mozilla 1

Status
Not open for further replies.

cramd

Programmer
Mar 28, 2001
214
US
I have a table that should display an image on the left and the corresponding description on the right. With the following code in IE 6.0 all works well - with Mozilla, I get the path to my image displayed as text--not the image, and on the right the description is displayed as it should be. I tried to change my code according to sample code from the W3c.org site--and I understand what the code is doing--but it fails in both IE 6.0 and Mozilla. IE states that ""A reference to variable or parameter 'image-dir' cannot be resolved. The variable or parameter may not be defined, or it may not be in scope."" MOZILLA's error---Error during XSLT transformation: (null)--- Right now I'm testing a simple table that will display only an image -
XML FILE.............
<?xml version=&quot;1.0&quot; encoding=&quot;ISO-8859-1&quot;?>
<?xml-stylesheet type=&quot;text/xsl&quot; href=&quot;photo.xsl&quot;?>

<photograph>
<href>hats.jpg</href>
<size width=&quot;300&quot;/>
</photograph>
.................................
XSL FILE........................
<?xml version=&quot;1.0&quot; encoding=&quot;ISO-8859-1&quot; ?>
<xsl:stylesheet version=&quot;1.0&quot; xmlns:xsl=&quot; <xsl:template match=&quot;/&quot;>
<html>
<body bgcolor=&quot;#FFFFCC&quot;>
<h2 align=&quot;center&quot;>INVENTORY ITEM</h2>
<table border=&quot;1&quot;>
<tr bgcolor=&quot;#0066FF&quot;>
<th align=&quot;center&quot;>IMAGE</th>
<th align=&quot;center&quot;>DESCRIPTION</th>
</tr>
<tr>
<td>
<xsl:variable name=&quot;image-dir&quot;>/WebsphereWork/images</xsl:variable>
<xsl:apply-templates select=&quot;photograph&quot; />
</td>
</tr>
</table>
</body>
</html>
</xsl:template>

<xsl:template match=&quot;photograph&quot;>
<img src=&quot;{$image-dir}/{href}&quot; width=&quot;{size/@width}&quot; />
</xsl:template>
</xsl:stylesheet>
...................................................

Any pointers on my continuing IE6/Mozilla dilemma.....
cramd
 


try this


<xsl:element name=&quot;IMG&quot;>
<xsl:attribute name=&quot;src&quot;>{$image-dir}/{href}/xsl:attribute>
<xsl:attribute name=&quot;width&quot;>{size/@width}</xsl:attribute>
</xsl:element>

 
I think I'm closer......no errors on either IE6 or on Mozilla, but all that displays is my header row....but no errors.....
Is this what you meant for me to change??.....
(I put your code within my template match photograph)

<xsl:template match=&quot;photograph&quot;>
<xsl:element name=&quot;IMG&quot;>
<xsl:attribute name=&quot;src&quot;>{$image-dir}/{href}</xsl:attribute>
<xsl:attribute name=&quot;width&quot;>{size/@width}</xsl:attribute>
</xsl:element>
</xsl:template>
</xsl:stylesheet>

Thanks for your thoughts...
cramd


 
simonchristieis:
You earn a star! Your post was enough to get me searching further.....I have FINALLY been able to bring in my images in both browsers IE6 & Mozilla!!
Another browser dilemma....solved!
cramd
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top