sboag 00/02/17 10:28:55
Modified: src/org/apache/xalan/xpath/xml FormatterToXML.java
src/org/apache/xalan/xslt StylesheetRoot.java
Log:
Fixed regression caused by trying not to flush the characters if the writer
is passed in by the user.
Revision Changes Path
1.24 +36 -8
xml-xalan/src/org/apache/xalan/xpath/xml/FormatterToXML.java
Index: FormatterToXML.java
===================================================================
RCS file:
/home/cvs/xml-xalan/src/org/apache/xalan/xpath/xml/FormatterToXML.java,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -r1.23 -r1.24
--- FormatterToXML.java 2000/02/17 13:06:25 1.23
+++ FormatterToXML.java 2000/02/17 18:28:54 1.24
@@ -372,7 +372,6 @@
m_pos = 0;
initCharsMap();
}
-
/**
* Initialize the serializer with the specified writer and output format.
@@ -383,7 +382,20 @@
*/
public synchronized void init( Writer writer, OutputFormat format )
{
- m_shouldFlush = false;
+ init( writer, format, false );
+ }
+
+
+ /**
+ * Initialize the serializer with the specified writer and output format.
+ * Must be called before calling any of the serialize methods.
+ *
+ * @param writer The writer to use
+ * @param format The output format
+ */
+ private synchronized void init( Writer writer, OutputFormat format,
boolean shouldFlush )
+ {
+ this.m_shouldFlush = shouldFlush;
this.m_writer = writer;
// This is to get around differences between Xalan and Xerces.
// Xalan uses -1 as default for no indenting, Xerces uses 0.
@@ -442,7 +454,7 @@
{
m_bytesEqualChars = true;
m_outputStream = output;
- init( (Writer)null, format );
+ init( (Writer)null, format, true );
}
else
{
@@ -483,7 +495,7 @@
osw = new OutputStreamWriter(output);
}
}
- init( osw, format );
+ init( osw, format, true );
}
}
@@ -561,6 +573,7 @@
outputLineSep();
}
flush();
+ flushWriter();
}
/**
@@ -1003,6 +1016,25 @@
throw new SAXException(ioe);
}
}
+
+ /**
+ * Flush the formatter's result stream.
+ */
+ public final void flushWriter()
+ throws SAXException
+ {
+ if(m_shouldFlush && (null != this.m_writer))
+ {
+ try
+ {
+ this.m_writer.flush();
+ }
+ catch(IOException ioe)
+ {
+ throw new SAXException(ioe);
+ }
+ }
+ }
private final void flushChars()
throws SAXException
@@ -1010,10 +1042,6 @@
try
{
this.m_writer.write(m_charBuf, 0, m_pos);
- if(m_shouldFlush)
- {
- this.m_writer.flush();
- }
m_pos = 0;
}
catch(IOException ioe)
1.24 +1 -1 xml-xalan/src/org/apache/xalan/xslt/StylesheetRoot.java
Index: StylesheetRoot.java
===================================================================
RCS file: /home/cvs/xml-xalan/src/org/apache/xalan/xslt/StylesheetRoot.java,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -r1.23 -r1.24
--- StylesheetRoot.java 2000/02/17 13:06:27 1.23
+++ StylesheetRoot.java 2000/02/17 18:28:55 1.24
@@ -574,7 +574,7 @@
}
this.m_encoding = encoding;
-
+
String javaEncoding =
FormatterToXML.convertMime2JavaEncoding(encoding);
Writer w = new OutputStreamWriter( ostream, javaEncoding );