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

Output non-XML string with XT v.19991105

Subject: Output non-XML string with XT v.19991105
From: "Xu, Xiaocun" <XXu@xxxxxxxxxxxx>
Date: Wed, 14 Mar 2001 11:43:24 -0500
xml string with
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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

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.
Email
First Name
Last Name
Company
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.