adding alt tags

N

N9

Hi,

<xsl:template match="Field[@Name='Image']">

<xsl:copy-of select="img"/>
<xsl:copy-of select="a"/>

</xsl:template>

Tht ouput is:

<img src="/files/teaser billeder/basillikum.jpg" style="" />

But can i adding a attribute, so the result is?

<img src="/files/teaser billeder/basillikum.jpg" style="" alt=""/>

Best regards

N9
 
M

Martin Honnen

N9 said:
<xsl:template match="Field[@Name='Image']">

<xsl:copy-of select="img"/>
<xsl:copy-of select="a"/>

</xsl:template>

Tht ouput is:

<img src="/files/teaser billeder/basillikum.jpg" style="" />

But can i adding a attribute, so the result is?

<img src="/files/teaser billeder/basillikum.jpg" style="" alt=""/>

You can add an attribute to the img element but not if you use
xsl:copy-of. Use
<xsl:template match="Field[@Name='Image']">
<xsl:apply-templates select="img"/>
<xsl:copy-of select="a"/>
</xsl:template>

<xsl:template match-"Field/img">
<xsl:copy>
<xsl:copy-of select="@*"/>
<xsl:attribute name="alt"></xsl:attribute>
</xsl:copy>
</xsl:template>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top