[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

CDATA / UTF-8 / Special Characters

Subject: CDATA / UTF-8 / Special Characters
From: "Erkkila, Matthew" <ErkkilaM@xxxxxxxxxxxx>
Date: Wed, 21 Sep 2005 12:41:12 -0600
utf 8 special characters
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


Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
First Name
Last Name
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.