Forum Moderators: open
I keep the path to the image in the xml file like this:
<top_photo1>/website/images/ExtView3.jpg</top_photo1>
and I am not sure what xslt syntax to use to transform it into the appropriate html i.e.:
<img style="float:left; margin-right:0px; margin-bottom:0px" src="/website/images/ExtView3.jpg" alt="=" title="Home" />
Currently I have tried many variations of this but none work:
<xsl:template match="/">
...
<img stlye="float:left; margin-right:0px; margin-bottom:0px" src="{top_photo1}" alt="=" title="Home" />
...
</xsl:template>
</xsl:transform>
Please note, all my other data transforms perfectly just not the images.
**Any pointers would be greatly appreciated.
When you run the transform in your web browser and examine the HTML source that is generated, what is the URL to the image in the img src tag?
Is the src tag completely empty, or does it have a duff URL?
If empty, I'd suggest playing about with the XPATH in your <xsl:template match="/"> or possibly trying a syntax like this until you isolate the problem:
<img style="..." alt="="><xsl:attribute name="src"><xsl:value-of select="//top_photo1" /></xsl:attribute></img>
If for example your XML looked like
<article>
<date>19 Sep 2005</date>
<header>
<top_photo1>/website/images/ExtView3.jpg</top_photo1>
<author>Jane Doe</author>
</header>
<body>
<p>Main body of the article here.</p>
</body>
</article>
you could write
<xsl:template match="/">
...
<img style="float:left; margin-right:0px; margin-bottom:0px" src="{article/header/top_photo1}" alt="" title="Home" />
...
</xsl:template>
or for more flexibility perhaps
<xsl:template match="/">
<xsl:apply-templates />
</xsl:template>
...
<xsl:template match="header">
<img style="float:left; margin-right:0px; margin-bottom:0px" src="{top_photo1}" alt="" title="Home" />
</xsl:template>
...