Hi,
I'm using php XMLWriter to create XML dynamically for transformation with an XSL-File. The data is obtained from a database.
Some XML element values contain HTML with e.g. img-tags in it:
Code:
<page>
<text>
Here are some images: <img src="pic1.jpg" > und <img src="pic.jpg">
</text>
</page>
As you can see the contents are automatically escaped (using e.g. php->XMLWriter->createElement()).
Now I would like to change the path of the images set in the src-attribute of the img-tags to e.g. images/pic1.jpg and imgaes/pic2.jpg. I want to avoid storing the location of the images within the HTML-contents.
Here's my approach that doesn't work:
Code:
<xsl:param name="urlImages" select="'images/'"/>
<xsl:template match="page/text">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="text()">
<xsl:value-of select="."/>
</xsl:template>
<xsl:template match="img/@src">
<xsl:attribute name="src">
<xsl:value-of select="concat($urlImages,.)"/>
</xsl:attribute>
</xsl:template>
Question:
Is there a way to access the src-attribute of the img-tags?
Thanks and best regards
polarbear