I have an XHTML field attached via a DataReference to another datatype, but cannot output it onto a page as unescaped HTML code. It either comes in escaped, or as an attribute to the containing DIV block.
My XML results:
What am I doing wrong?
My XML results:
<in:inputs xmlns:in="http://www.composite.net/ns/transformation/input/1.0">
<in:result name="GetDataXml">
<Data Id="3151c798-8c43-4834-bcbd-f1a47035f0e8" SubData.Body="<html xmlns="http://www.w3.org/1999/xhtml"> <head></head> <body></body> </html>" xmlns=""/>
</in:result>
</in:inputs>
My XSLT:<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:in="http://www.composite.net/ns/transformation/input/1.0"
xmlns:lang="http://www.composite.net/ns/localization/1.0"
xmlns:f="http://www.composite.net/ns/function/1.0"
xmlns="http://www.w3.org/1999/xhtml"
exclude-result-prefixes="xsl in lang f">
<xsl:variable name="data" select="/in:inputs/in:result[@name='GetDataXml']" />
<xsl:template match="/">
<html>
<head />
<body>
<xsl:choose>
<xsl:when test="count($data/Data) = 1">
<xsl:apply-templates select="$data/Data" />
</xsl:when>
<xsl:otherwise>
<p>Zero or more than 1 results</p>
</xsl:otherwise>
</xsl:choose>
</body>
</html>
</xsl:template>
<xsl:template match="*">
<h2>Body:</h2>
<xsl:choose>
<xsl:when test="@SubData.Body != ''">
<xsl:copy-of select="@SubData.Body"/>
</xsl:when>
<xsl:otherwise>
<p>Nothing to display</p>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
This gives me an error of:XslTransformException: Attribute and namespace nodes cannot be added to the parent element after a text, comment, pi, or sub-element node has already been added.If I use:
<div><xsl:copy-of select="@SubData.Body"/></div>
... instead, I get an output of:<div SubData.Body="<html xmlns="http://www.w3.org/1999/xhtml"> <head></head> <body></body> </html>"/>
I've also tried using <xsl:value-of select="@SubData.Body" disable-output-escaping="yes" />, but that doesn't work either.What am I doing wrong?