list4xt : Mailing list for the XT users community.
[list4xt] Output non-XML string
Subject: [list4xt] Output non-XML string
User: Website From: Xu, Xiaocun (XXu@Emptoris.com)
Date: 14/03/2001 - 15:52
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@emptoris.com
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");
}
--
Mailing list for the XT users community. (http://higheredtechsummit.com)
(mailto:list4xt-request@4xt.org?Subject=unsubscribe to unsubscribe)
Archive générée par hypermail 2b28 le 25/04/2001 - 07:16 CEST
webmaster@4xt.org
|