tags:

views:

41

answers:

3
<input src="LOGO.JPG" type="image" name="imagem">

I have an xml element that contains the image path that needs to be displayed in HTML after the parse. <xsl:value-of select="image"/> returns the string that is stored in the image element but how can I use it to make that string be the src atribute value in an html tag? I tried <input src="<xsl:value-of select="image"/>" type="image" name="imagem"> but obviously that doesn't work so how can it be done?

I hope I was clear in my question. Please help!

A: 

This should work:

<input type="image" name="imagem">
    <xsl:attribute name="src"><xsl:value-of select="image" /></xsl:attribute>
</input>
Dan
I get the error "Unexpected atribute" and select="image" highlighted in my editor. I tried a various combination of xpath expressions and this error persisted.
AtomR
The select attribute on xsl:attribute was introduced on XSLT 2.0
Max Toro
I updated my reply accordingly.
Dan
+1  A: 
<input type="image" name="imagem" src="{image}" />
Max Toro
Thank you. This worked perfectly.
AtomR
A: 

Do you mean?:

<xsl:template select="//image">
    <xhtml:img>
        <xsl:attribute name="alt"><xsl:value-of="@name" /></xsl:attribute>
        <xsl:attribute name="src"><xsl:value-of="@src" /></xsl:attribute>
    </xhtml:img>
</xsl:template>

Remember to bind the namespace prefixes correctly. Also, img elements in HTML must have an alt.

alternatively replace "//image" with the specific Xpath to your XML element.

Lajla