I have a scenario where CDATA is returning html tags, so I have to use disable-output-escaping="yes" to render the content correctly to a html page. However, the CDATA can also include ampersand characters, this is causing my pages to fail w3c validation.
Here's an example of my xml source:
<?xml version="1.0" encoding="UTF-8"?>
<jobs>
<job>
<positionTitle><![CDATA[Health & Safety Officer]]></positionTitle>
<description1><![CDATA[<p>You must have experience of working in a health & safety team.</p>]]></description1>
</job>
</jobs>
XSLT
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:content="http://purl.org/rss/1.0/modules/content/" >
<xsl:output method="html"/>
<xsl:template match="/">
<xsl:for-each select="jobs/job">
<div class="job">
<div class="title"><h3><xsl:value-of select="positionTitle"/></h3></div>
<div class="description"><xsl:value-of select="description1" disable-output-escaping="yes"/></div>
</div>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
Results in:
<div class="title">
<h3>Health & Safety Officer</h3>
</div>
<div class="description">
<p>You must have experience of working in a health & safety team.</p>
</div>
The & character within the description element is failing validation, how do i convert the &
to &
?
thanks