Re: [xsl] Output non-XML string with XT v.19991105

Subject: Re: [xsl] Output non-XML string with XT v.19991105
From: Johannes Döbler <jd@xxxxxxxxxxxxxx>
Date: Wed, 14 Mar 2001 18:49:22 +0100
What encoding do you use?
Unfortunatly Java uses different names than XML for some encodings.
If the (Java based) processor does not translate these encoding names before opening its output stream you will typically get such an error.


Johannes

At 11:43 14.03.01 -0500, you wrote:
Hi,

        I have been using XSLT for almost a year now.  In my past projects,
I have been using Saxon and Xalan due to the transformation required
xsl:key.  In my current project, I have started to explore XT for the
performance improvement it provides.
        Currently, I ran into a problem trying to output non-XML string.  It
always seems to give me a problem at xsl.parse, getting a
NullPointerException with OutputStreamWriter (code and exception at end of
email).
        The weird thing is, my method outputs XML string is just fine.  Also
I have another xt() method with a different signature outputs to a file
instead of string, that works fine for both XML and non-XML output.  Also,
both Saxon and Xalan methods I have ouputs XML and non-XML string just fine.
So I am little perplexed as what causes this exception ONLY when using XT
outputs non-XML string.  Any help and suggestions would be most welcomed.

Thanks,

Xiaocun Xu
Emptoris, Inc.
xxu@xxxxxxxxxxxx

Exception:
Exception in thread "main" java.lang.NullPointerException:
        at sun.io.Converters.getConverterClass(Converters.java:82)
        at sun.io.Converters.newConverter(Converters.java:128)
        at
sun.io.CharToByteConverter.getConverter(CharToByteConverter.java:71)
        at java.io.OutputStreamWriter.<init>(OutputStreamWriter.java:78)
        at
com.jclark.xsl.sax.GenericDestination.getWriter(GenericDestination.java)
        at com.jclark.xsl.sax.TextOutputHandler.init(TextOutputHandler.java)
        at
com.jclark.xsl.sax.OutputMethodHandlerImpl.createDocumentHandler(OutputMetho
d
HandlerImpl.java)
        at com.jclark.xsl.sax.ResultBase.setOutputMethod(ResultBase.java)
        at com.jclark.xsl.sax.ResultBase.start(ResultBase.java)
        at com.jclark.xsl.tr.SheetImpl.process(SheetImpl.java)
        at com.jclark.xsl.sax.XSLProcessorImpl.parse(XSLProcessorImpl.java)
        at Converter.xt(Converter.java:158)

Code:
    private static String xt(String inputXML, String stylesheet) {
        try {
        XSLProcessorImpl xsl = new XSLProcessorImpl();
        setParser(xsl);

        OutputMethodHandlerImpl outputMethodHandler = new
OutputMethodHandlerImpl(xsl);
        xsl.setOutputMethodHandler(outputMethodHandler);

            ByteArrayOutputStream dstWriter = new ByteArrayOutputStream();
        Destination dest = new OutputStreamDestination(dstWriter);
        outputMethodHandler.setDestination(dest);

xsl.loadStylesheet(fileInputSource(new File(stylesheet)));

xsl.parse(new InputSource(new StringReader(inputXML) ));

            return(dstWriter.toString());
        }
        catch (SAXParseException e) {
            printSAXParseException(e);
        }
        catch (SAXException e) {
            System.err.println(e.getMessage());
        }
        catch (IOException e) {
            System.err.println(e.toString());
        }
        return("FALSE");
    }



XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list


XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list


Current Thread