[xsl] CDATA / UTF-8 / Special Characters

Subject: [xsl] CDATA / UTF-8 / Special Characters
From: "Erkkila, Matthew" <ErkkilaM@xxxxxxxxxxxx>
Date: Wed, 21 Sep 2005 12:41:12 -0600
Forgive me if this is a simple question I am rather new to xslt.  I have
a java program that uses the Xalan processor to translate xml into html.
There are two translations that happen and the output of the first is
wrapped in a CDATA section and used as the input for the second (See

The data for the first xml listed below comes from a database that was
originally entered by copy/paste from a word document.  So the single
and double quotes are the word version.

The first translation works perfectly but the second translation somehow
destroys the single and double quotes and other characters.  So when I
output them to the browser they show up as ? (question marks/invalid
characters).  Xalan is set to use utf8 for the encoding and all the
xml/xslt documents have utf8 encoding declared.  Anyone have any ideas?

Thanks for the help.

/********************* XML1 **************************************/
<?xml version="1.0" encoding="UTF-8"?>
    <TITLE>This is the title</TITLE>
    <BODY>This is the &lt;bold&gt;body&lt;/bold&gt; of an
article.</BODY> <!-- This may contain html. -->

Gets translated using something like

/******************************** XSLT1 *****************************/
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
<xsl:template match="ARTICLE">
   <span><xsl:value-of select="TITLE" disable-output-escaping="yes"
   <div><xsl:value-of select="BODY" disable-output-escaping="yes"

Then combined in java to form a new xml document like

/************************** XML2 ******************************/
<?xml version="1.0" encoding="UTF-8"?>
<span>This is the title</span>
<div>This is the <bold>body</bold> of an article.</div>

Translated using

/************** XSLT2 *******************************************/
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0"

<xsl:output method="html" encoding="UTF-8" indent="yes"/>
<xsl:template match="PAGE">
  <table cellpadding="0" cellspacing="0" border="0">
    <xsl:for-each select="WIDGET[@POSITION=1]">
      <xsl:sort select="@RANK" data-type="number" order="ascending" />
      <xsl:value-of select="." disable-output-escaping="yes" />

Current Thread