p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   XSLT (http://p2p.wrox.com/forumdisplay.php?f=86)
-   -   Image not displaying properly but I path correct (http://p2p.wrox.com/showthread.php?t=53022)

DrGonzo January 22nd, 2007 12:58 AM

Image not displaying properly but I path correct

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"?>
  <Photograph PhotographId="1">
  <Photograph PhotographId="2">

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="/">
    <h2>Gallery Test</h2>
      <tr bgcolor="#3ff455">
        <th>Pic Name</th>
      <xsl:for-each select="Photographs/Photograph[@PhotographId &lt; 3]">
        <td><xsl:value-of select="Camera"/></td>
        <td><xsl:value-of select="Name"/></td>
            <xsl:attribute name="src">
              "./Pics/Thumbs/<xsl:value-of select='Name'/>.JPG"

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

joefawcett January 22nd, 2007 05:14 AM

Search for Attribute Value Templates in an XSLT reference, you need something like:

<img src="./Pics/Thumbs/{Name}"/>

Joe (Microsoft MVP - XML)

All times are GMT -4. The time now is 06:45 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.