Ok,  Now all 8 bit (standard text) xsl sheets work again (called
setNamespaceAware(true) before building the DOM, thanks), but unicode
stylesheets still cause transformer to complain of a missing version attribute.

setUnicodeAware(true)??... :-)

If the DocumentFactory is mindful of the encoding of the document, then
why would that make a difference?  I am able to display the DOM and it
looks ok, contains a version attribute even, but for some reason the
transformer can't find the XSL version attribute.

Both xsl documents are identical, except that one is unicode and the
other is text.

Code is enclosed.  I'll play with the transformer command line, when I
can find it.

Hmm, I do call <xsl:import href="common/zh/html/PageLayout.xsl"> and
that file is
still 8 bit.  Wonder if mixing them causes problems.

Gary L Peskin wrote:
> 
> Be sure that you setNamespaceAware(true) on DocumentBuilderFactory
> before creating your DocumentBuilder.  In other words, you need to be
> sure that namespace support is on when you build your DOM.
> 
> Gary
> 
> > -----Original Message-----
> > From: Christopher Hull [mailto:[EMAIL PROTECTED]]
> > Sent: Thursday, September 20, 2001 4:29 PM
> > To: '[EMAIL PROTECTED]'
> > Subject: Problem using DOMSource with tFactory.newTransformer
> >
> >
> >
> > Simply, when I pass a DOM, newTransformer complains that the
> > stylesheet does not have a version attribute when it does.
> > When I pass in a StreamSource, everything works, but the
> > StrreamSource doesn't appear to deal with unicode properly
> > (that is, stylesheets saved as unicode don't appear to work).
> >
> > Using XalanJ 2_0_0
> >
> > Any ideas?
> > 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.
                
                @param String - Filename
                @returns Document - XML document.
        */
        private Document readXMLFile(String xmlFile)
                throws IOException, SAXException,
ParserConfigurationException {
        
                debug.out("readXMLFile() [begin] opening XML file: " + xmlFile);
                Document xmlDoc = null;
        
                FileInputStream inXMLStream = null;
                Reader                  xmlReader       = null;
                InputSource             xmlSource       = null;

                //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.
                xmlDoc = dBuilder.parse( new File(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>
    
-- 

Christopher Hull
Engineering Group Manager, Senior Software Architect
Mediagate Inc.
iPost Card     http://web.mediagate.com/chris.hull
iPost Voice    408 261 7201
email          [EMAIL PROTECTED]

Reply via email to