Ok, just upgraded to Xalan 2_2_D10 /w associated Xerces.  

DocumentBuilder appears to ignore the xml encoding=UTF-8.  Chinese
characters are converted to ???.

The style sheet was authored in WordPad under Windoes 2000 and saved as
a unicode
document.  I do open a FileInputStream, as opposed to a file, before building
my DOM.  When I traverse and print, the Chinese text nodes turn to ???.  

I also tried just feeding transformer (StreamSource(FileInputStream)),
and got the same result, except I could not spit out the DOM before
doing the transform.

How do I preserve the XSL document's encoding?
What am I doing wrong.

Thanks;
-Chris



/**
                Given a filename which points to an XSL file.  Create a new
                Transformer.
                @param String - Filename
                @return Transformer - A pre-processed XSL document.
        */
        private Transformer readTransformer(String fileName)
                throws TransformerException,
TransformerConfigurationException, 
FileNotFoundException,
                ParserConfigurationException, SAXException, IOException {
        
                debug.out("readTransformer() [begin] buinding
Transformer for XSL file: "
+ fileName);
                
                TransformerFactory tFactory =
TransformerFactory.newInstance(); 
        tFactory.setURIResolver( new Resolver() );

                Document d = readXMLFile(fileName);
                TreePrinter.printTree(d);

                                // XXX TransformerConfigurationException stylesheet
requires 
                                //  attribute: version
                Transformer t = tFactory.newTransformer(
                        new DOMSource( d ));

                debug.out("readTransformer() [end] returning Transformer
" + t);
                return t;       
        }
        
                
        /**
                Given a FileInputStream, read in the file and build a DOM.

                XXX The document returned converts all Chinese to ????

                @param String - Filename
                @returns Document - XML document.
        */
        private Document readXMLFile(String xmlFile)
                throws IOException, SAXException,
ParserConfigurationException {
        
                debug.out("readXMLFile() [begin] opening XML file: " + xmlFile);

                //Instantiate a DocumentBuilderFactory.
                DocumentBuilderFactory dFactory = DocumentBuilderFactory.newInstance();
                dFactory.setNamespaceAware(true);
                
                 //Use the DocumentBuilderFactory to create a DocumentBuilder.
                DocumentBuilder dBuilder = dFactory.newDocumentBuilder();

                //Use the DocumentBuilder to parse the XML input.
                Document xmlDoc = dBuilder.parse( new
FileInputStream(xmlFile) );


                debug.out("readXMLFile() [end] returning DOM " + xmlDoc);
                return xmlDoc;  
        }
    

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>


   <xsl:import href="common/zh/html/PageLayout.xsl">
   </xsl:import>

Reply via email to