|
Subject: [xsl] Output non-XML string with XT v.19991105 From: "Xu, Xiaocun" <XXu@xxxxxxxxxxxx> Date: Wed, 14 Mar 2001 11:43:24 -0500 |
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 |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| Antwort: [xsl] copying source tree, Ulrich Becker | Thread | Re: [xsl] Output non-XML string wit, Johannes Döbler |
| Re: [xsl] [exsl] EXSLT 1.0 Drafts 0, Dave Hartnoll | Date | Re: [xsl] Testing for Parent Nodes , David Carlisle |
| Month |