I have an issue with calling an image across to my transformed xsl file.
It seems to be something very simple, yet I can't find a solution to it. I have tried searching on here already and using the various similar answers provided but have had no luck.
I'm trying to use the string inside
<image>string</image>
as the filepath to display my graphic.
Any resultant I've tried always gives me the small broken graphic icon.
Thanks in advance.
EDIT: I'll be more specific. (Sorry it's been a long day)
I'm using Notepad++, with the "XML Tools" plugin, I can apply the XSL Transformation by specifying the xsl file when I am focused on the XML file. Where I save it as a newly created html file.
Opening it should display all my data + the image. But instead, I get the placeholder instead for when a graphic cannot be located. (i.e. in Internet Explorer its the small icon with the red cross.)
Using the stylesheet method call at the start of the file should also allow me to view the transformation without the need to create any new file using Firefox. But it also fails to display.
Here is my XML:
<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet href="aperture_event_page.xsl" type="text/xsl"?>
<listings
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="aperture_venues.xsd">
<venue id="apv_01">
<image>/images/apv_01.png</image>
<other elements></other elements>
...
<more elements>
<elements></elements>
...
</more elements>
</venue>
<venue id="apv_02">
#repeat#
</venue>
<venue id="apv_03">
#repeat#
</venue>
<venue id="apv_04">
#repeat#
</venue>
</listings/>
and my XSL:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" omit-xml-declaration="yes"/>
<xsl:template match="/">
<xsl:element name="html">
<xsl:element name="head">
<xsl:element name="title">Event</xsl:element>
</xsl:element>
<xsl:element name="body">
<xsl:element name="image">
<img src="{image}"/>
</xsl:element>
<xsl:apply-templates select="/listings/venue/image"/>
</xsl:element>
</xsl:element>
</xsl:template>
Using xsl:text, I was able to specify the image path url and then take in the image element string as the filename to complete the full path.
You're using
<xsl:element>
where you don't need it and failing to use it in the one place you do.There's not quite enough here to tell me what you're after completely, but this should get you closer:
This will produce a sequence of html
<img>
tags with thesrc
attribute properly containing an image path from each<image>
tag in your original xml.If you want your output to be xhtml instead of plain html (and thus have the tags properly terminated as xml), you could change the output-method to "xml" if you're using XSL 1.0 or "xhtml" if you're using XSL 2.0.