View Single Post
  #1 (permalink)  
Old January 22nd, 2007, 12:58 AM
DrGonzo DrGonzo is offline
Registered User
 
Join Date: Jan 2007
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to DrGonzo
Default Image not displaying properly but I path correct

Hi,

I am only new to XSLT, only started this morning! I have a XML file containing details of photographs:

<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="Test.xsl"?>
<Photographs>
  <Photograph PhotographId="1">
    <Name>100_2209</Name>
    <Camera>Kodak</Camera>
    <FocalLength>4.5</FocalLength>
    <Exposure>0</Exposure>
  </Photograph>
  <Photograph PhotographId="2">
    <Name>100_2228</Name>
    <Camera>Kodak</Camera>
    <FocalLength>5</FocalLength>
    <Exposure>+2</Exposure>
  </Photograph>
</Photographs>

I only store the name of the photograph (in above example 100_2228) rather than the full path of the thumbnail (./Pics/Thumbs/100_2228.jpg) and the full image (./Pics/Full/100_2228.jpg). I only store the name to avoid storing duplicate data as I will eventually be storing thousands of photographs.

My XSL file displays these photographs and is as follows:

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
  <html>
  <body>
    <h2>Gallery Test</h2>
     <table>
      <tr bgcolor="#3ff455">
        <th>Camera</th>
        <th>Pic Name</th>
        <th>Pic</th>
      </tr>
      <xsl:for-each select="Photographs/Photograph[@PhotographId &lt; 3]">
      <tr>
        <td><xsl:value-of select="Camera"/></td>
        <td><xsl:value-of select="Name"/></td>
        <td>
          <img>
            <xsl:attribute name="src">
              "./Pics/Thumbs/<xsl:value-of select='Name'/>.JPG"
            </xsl:attribute>
         </img>
        </td>
      </tr>
      </xsl:for-each>
    </table>
  </body>
  </html>
</xsl:template>
</xsl:stylesheet>

As a test I just returned "./Pics/Thumbs/<xsl:value-of select='Name'/>.JPG" as a string to the screen and the path is correct, it should show an image but all that happens is the box with X in it. If I add an image on a page and set src to the path returned by "./Pics/Thumbs/<xsl:value-of select='Name'/>.JPG" then the image is displayed as it should.

Any suggestions as to why it is not being displayed? There are no errors shown, just no image displayed! Thanks
Reply With Quote