list4xt : Mailing list for the XT users community.
[list4xt] Re: Output non-XML string
Subject: [list4xt] Re: Output non-XML string
From: Thach, Tai (tai.thach@sapmarkets.com)
Date: 14/03/2001 - 19:05
Hi,
I had this problem too when I used
com.jclark.xsl.sax.OutputStreamDestination to handle the output stream. If
you compare the the getOutputStream method of this class with the same
method of the other *Destination classes, you'll see that in this one, the
encoding is never set. This is what is causing the NullPointerException. The
XT code tries to use the value for the encoding later on, thus causing the
exception. All that I did to fix the problem was to add one line of code to
set the encoding.
I've included an updated JAR file that has the fix in it and also the source
to the code that I changed.
Hope that helps.
Tai
BTW, is there a process yet for submitting changes to the code?
-----Original Message-----
From: Xu, Xiaocun [mailto:XXu@Emptoris.com]
Sent: Wednesday, March 14, 2001 6:53 AM
To: 'list4xt@4xt.org'
Cc: Xu, Xiaocun
Subject: [list4xt] Output non-XML string
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://howdoiacceptcreditcards.com)
(mailto:list4xt-request@4xt.org?Subject=unsubscribe to unsubscribe)
-- Binary/unsupported file stripped by Listar --
-- Type: application/octet-stream
-- File: xt.jar
-- Binary/unsupported file stripped by Listar --
-- Type: application/octet-stream
-- File: OutputStreamDestination.java
--
Mailing list for the XT users community. (http://w3talk.com)
(mailto:list4xt-request@4xt.org?Subject=unsubscribe to unsubscribe)
Archive générée par hypermail 2b28 le 06/11/2001 - 11:46 CET
webmaster@4xt.org
|