Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries >Thread Prev - xsl:if test for empty tag >Thread Next - Re: xsl:if test for empty tag Re: xsl:if test for empty tagTo: NULL Date: 10/6/2005 4:54:00 PM Jonathan Crawford wrote:
> Hi
>
> I am perilously new at this.
> I have an xml file which may
> or not return an image in an <image> tag
> If there is no image there is no tag
> (though I could have an empty tag)
>
> I figure I should do something like this
>
> <xsl:if test="@image <> null">
> <img>
> <xsl:attribute name="src">
> <xsl:value-of select="image"/>
> </xsl:attribute>
> </img>
> <xsl:if>
>
> but I am just gusessing as no samples I can find
> do anything like this. I would be grateful for some help
> as I have been stuck for hours
Try this:
<xsl:if test="image">
<img>
<xsl:attribute name="src">
<xsl:value-of select="image"/>
</xsl:attribute>
</img>
<xsl:if>
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
