Skip to main content
Inspiring
August 28, 2008
Question

xmlTransform() and an Unnecessary XML declaration

  • August 28, 2008
  • 1 reply
  • 203 views
Is there a way to stop this code from producing an unnecessary XML
declaration. When I run the following code it produces an XML
declaration after the body tag.

<body>
<?xml version="1.0" encoding="UTF-8"?>

Is there someway to control this, or do I just need to do some string
parsing after the transformation?

<cfsavecontent variable="displayXSL">
<xsl:stylesheet version="1.0"
xmlns:xsl=" http://www.w3.org/1999/XSL/Transform">

<xsl:template match="table/thead" />

<xsl:template match="table/tr">
<div>
<strong><xsl:value-of select="td[1]"/></strong>
</div>
</xsl:template>

</xsl:stylesheet>
</cfsavecontent>

</cfsilent><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
" http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns=" http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=utf-8" />
<title>XSLT Fun</title>
</head>

<body>
<cfoutput>#xmlTransform(skillsXML,displayXSL)#</cfoutput>
</body>
</html>

This topic has been closed for replies.

1 reply

Inspiring
August 28, 2008
Ian Skinner wrote:
> Is there a way to stop this code from producing an unnecessary XML
> declaration.

Why yes, yes there is a way to stop this. Add the following line to
your XSLT code Ian.

<xsl:output method="html" encoding="utf-8"/>