Amiya Behera
Amiya Behera

Reputation: 2270

Converting to img tag in xlst

This is my xml file:

<xml>
<figure>abstract.png</figure>
</xml>

This is my xslt code:

<xsl:template match="figure">
<img src="{.}" alt=""/>
<xsl:value-of select="."/>
</xsl:template>

But it gives this:

<img src="abstract.png" alt=""/>abstract.png

instead of just:

<img src="abstract.png" alt=""/>

How to remove the last abstract.png?

Upvotes: 0

Views: 43

Answers (1)

michael.hor257k
michael.hor257k

Reputation: 117102

The trailing string abstract.png is produced by your instruction:

<xsl:value-of select="."/>

If you remove it, you will get the expected result:
https://xsltfiddle.liberty-development.net/aiyndL

Upvotes: 1

Related Questions