Page 1 of 1

Using xsl Stylesheet - html view including images

Posted: Sun Nov 30, 2003 8:02 pm
by Marc
Hi George,

Thank you again for your help it works fine so far but I still have my problems with the "broken image". When I am using
<Bild>
<Pfad/> <!-- no path for a picture-->
</Bild>
in my xml document I will have a broken image (red X) in my html view.
How can I fix this problem? I don't want to have this "red X" instead I will have a text like "no picture available". I was trying the following:
<xsl:for-each select=".//Pfad">
<img alt="no picture available">
<xsl:attribute name="src">
<xsl:value-of select="."/>
</xsl:attribute>
</img>
The html view still show me the "red X" followed by my text "no picture available". Do you have an idea how to solve this problem? Only showing me my text and nothing else.

Thank you very much again.
cu Marc

Posted: Tue Dec 02, 2003 11:54 am
by george
Hi Marc,

You have to test if you have any text nodes and generate the img tag only if an image is specified:

Code: Select all


                <xsl:for-each select=".//Pfad">
<br/><br/>
<xsl:choose>
<xsl:when test="text()">
<img><xsl:attribute name="src"><xsl:value-of select="."/></xsl:attribute></img>
</xsl:when>
<xsl:otherwise>[No picture available]</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
Best Regards,
George
P.S. Please post your replies to the same topic.