1

Say I have an XML file with the following tag...

<pic> flower.jpg </pic>

I can transform my XML document into a HTML file using XSLT. However, my problem is HOW to output the actual image! All that displays in the browser is "flower.jpg", but obviously I want to see the actual picture!

What XSL code do I need so I can extract an image from every tag in my XML!?

Do I need to change my XML as well to do this? All the images are in a local folder!

I was told this could be done with the element in XSLT (linking to some "src" in the XML?). Is this possible?

Please help. Thank you. Edited...

Lisa Smith
  • 27
  • 6
  • Is the image actually in the XML (as a base64 encoded string) or does it just have the name? If it is just the name you just need to create the image tag in your XSLT pointing to the image If it is base64 encoded, see this post http://stackoverflow.com/questions/1684909/xslt-convert-base64-data-into-image-files – Dijkgraaf Oct 23 '13 at 02:37
  • It is just the name of the image. There is more than one image tag (each containing one image name), so how do you output all of them? – Lisa Smith Oct 23 '13 at 02:55
  • Then you need to do what Phil has answered. – Dijkgraaf Oct 23 '13 at 03:13

1 Answers1

0

It's been a while but something like this in your for-each or template match for the <pic> tag

<img>
    <xsl:attribute name="src">
        <xsl:value-of select="normalize-space(.)" />
    </xsl:attribute>
</img>
Phil
  • 157,677
  • 23
  • 242
  • 245