You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by Chris Brien <Ch...@au.uu.net> on 2000/12/04 08:40:55 UTC

unicode characters being displayed as ?

Hi,
	I am unable to use unicode caharcters in an xml-xslt transformation.
	The unicode caharcters always are displayed as a '?' character.

	I am using the sample program SessionExample.java, and the following
foo.xml:
	I hope I am just making a very simple mistake, so I appreciate any
help.



<?xml version="1.0"?>
<doc>\344\270\255\346\226\207</doc>

Here the the xsl file:

<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
  <xsl:template match="doc">
  <HTML>
    <HEAD>
      <STYLE type="text/css"></STYLE>
    </HEAD>
    <BODY>
        <p><xsl:value-of select="."/></p>
    </BODY>
  </HTML>
  </xsl:template>
</xsl:stylesheet>


Here is the source:

import java.io.*;
import java.text.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;

import org.xml.sax.SAXException;
import org.apache.xalan.xslt.XSLTProcessorFactory;
import org.apache.xalan.xslt.XSLTInputSource;
import org.apache.xalan.xslt.XSLTResultTarget;
import org.apache.xalan.xslt.XSLTProcessor;


/**
 * Example servlet showing request headers
 *
 * @author James Duncan Davidson <du...@eng.sun.com>
 */
public class SessionExample extends HttpServlet {

    ResourceBundle rb = ResourceBundle.getBundle("LocalStrings");

    public void doGet(HttpServletRequest request,
                      HttpServletResponse response)
        throws IOException, ServletException
    {
        // Have the XSLTProcessorFactory obtain a interface to a
        // new XSLTProcessor object.
        try
        {
            XSLTProcessor processor = XSLTProcessorFactory.getProcessor();

            // Have the XSLTProcessor processor object transform "foo.xml"
to
            // System.out, using the XSLT instructions found in "foo.xsl".
            processor.process(new XSLTInputSource("foo.xml"),
                              new XSLTInputSource("foo.xsl"),
                              new XSLTResultTarget(out));
        }
        catch (Exception e)
        {
            e.printStackTrace();
        }

        ps.close();
    }

    public void doPost(HttpServletRequest request,
                      HttpServletResponse response)
        throws IOException, ServletException
    {
        doGet(request, response);
    }