You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by Chris Lee <cs...@home.com> on 2000/12/05 02:14:59 UTC
Serializer Factor bug - StylesheetRoot.java
Patched both versions of MakeSAXSerializer to call SerializerFactory.
Note that this requires a patch to SerializerFactory.java to correctly load
custom factories.
// from StylesheetRoot.java:484
public DocumentHandler makeSAXSerializer( Writer writer, OutputFormat
format )
throws IOException
{
DocumentHandler handler;
if ( format == null )
{
format = new OutputFormat( "xml", "UTF-8", false );
handler = null;
}
if ( format.getMethod().equalsIgnoreCase( "text" ) )
{
handler = new FormatterToText(writer);
}
else
{
String method = format.getMethod();
SerializerFactory factory =
SerializerFactory.getSerializerFactory(method);
Serializer serializer = factory.makeSerializer(writer, format);
handler = serializer.asDocumentHandler();
}
return handler;
}
// from StylesheetRoot.java:548
public DocumentHandler makeSAXSerializer( OutputStream ostream,
OutputFormat format )
throws UnsupportedEncodingException, IOException
{
DocumentHandler handler = null;
if ( format == null )
{
format = new OutputFormat( "xml", "UTF-8", false );
handler = null;
}
if ( format.getMethod().equalsIgnoreCase( "text" ) )
{
String encoding = format.getEncoding();
if(null == encoding)
{
try
{
encoding = System.getProperty("file.encoding");
encoding = (null != encoding) ?
FormatterToXML.convertJava2MimeEncoding( encoding ) :
"ASCII";
if(null == encoding)
{
encoding = "ASCII";
}
}
catch(SecurityException se)
{
encoding = "ASCII";
}
}
this.m_encoding = encoding;
String javaEncoding =
FormatterToXML.convertMime2JavaEncoding(encoding);
Writer w = new OutputStreamWriter( ostream, javaEncoding );
handler = new FormatterToText(w);
}
else
{
String method = format.getMethod();
SerializerFactory factory =
SerializerFactory.getSerializerFactory(method);
Serializer serializer = factory.makeSerializer(ostream, format);
handler = serializer.asDocumentHandler();
}
return handler;
}