Using xsl Stylesheet - html view including images

Having trouble installing Oxygen? Got a bug to report? Post it all here.
Marc

Using xsl Stylesheet - html view including images

Post 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
george
Site Admin
Posts: 2095
Joined: Thu Jan 09, 2003 2:58 pm

Post 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.
Post Reply