costin 00/10/12 16:28:32
Modified: java/src/trax Result.java
java/src/org/apache/xalan/xslt XSLTResultTarget.java
Log:
Fix: if XSLTResultTarget is created with a File argument, we need
to return the right CharacterStream - TransformerImpl calls
getByteStream or getCharacterStream and both are null if file
is used ( resulting in a NPE in BaseMarkupSerializer.setOutputStream ).
I also changed the fields of trax.Result to protected - it is very
confusing to have the same field name in XSLTResultTarget and Result (
and it have unexpected effects ).
Revision Changes Path
1.5 +3 -3 xml-xalan/java/src/trax/Result.java
Index: Result.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/trax/Result.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- Result.java 2000/09/19 21:05:00 1.4
+++ Result.java 2000/10/12 23:28:32 1.5
@@ -181,7 +181,7 @@
// Internal state.
//////////////////////////////////////////////////////////////////////
- private OutputStream byteStream;
- private Writer characterStream;
- private Node node;
+ protected OutputStream byteStream;
+ protected Writer characterStream;
+ protected Node node;
}
1.2 +20 -3
xml-xalan/java/src/org/apache/xalan/xslt/XSLTResultTarget.java
Index: XSLTResultTarget.java
===================================================================
RCS file:
/home/cvs/xml-xalan/java/src/org/apache/xalan/xslt/XSLTResultTarget.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- XSLTResultTarget.java 2000/07/25 16:05:44 1.1
+++ XSLTResultTarget.java 2000/10/12 23:28:32 1.2
@@ -59,6 +59,10 @@
import org.w3c.dom.Node;
import java.io.OutputStream;
import java.io.Writer;
+import java.io.FileWriter;
+import java.io.OutputStreamWriter;
+import java.io.FileOutputStream;
+import java.io.IOException;
import org.xml.sax.DocumentHandler;
import trax.Result;
@@ -271,14 +275,27 @@
return formatterListener;
}
+ public Writer getCharacterStream() {
+ if( characterStream != null ) return characterStream;
+ if( fileName != null ) {
+ try {
+ if( encoding==null ) {
+ return new FileWriter( fileName );
+ } else {
+ return new OutputStreamWriter( new FileOutputStream( fileName ),
encoding);
+ }
+ } catch( IOException ex ) {
+ return null;
+ }
+ }
+ return null;
+ }
+
//////////////////////////////////////////////////////////////////////
// Internal state.
//////////////////////////////////////////////////////////////////////
private String fileName;
- private OutputStream byteStream;
private String encoding;
- private Writer characterStream;
- private Node node;
private DocumentHandler formatterListener;
}