serializer.getSerializerObject().setOutputFormat(props.getProperties());
((ParserAdapter)handler).setContentHandler(serializer.getSerializerObject());
}
else if ( format.getMethod().equalsIgnoreCase( "xml" ) )
{
FormatterToXML serializer = new FormatterToXML(ostream);
serializer.getSerializerObject().setOutputFormat(props.getProperties());
((ParserAdapter)handler).setContentHandler(serializer.getSerializerObject());
}
else if ( format.getMethod().equalsIgnoreCase( "text" ) )
{
String encoding = format.getEncoding();
if(null == encoding)
{
try
{
encoding = System.getProperty("file.encoding");
encoding = (null != encoding) ?
org.apache.xalan.serialize.Encodings.convertJava2MimeEncoding( encoding ) : "ASCII";
if(null == encoding)
{
encoding = "ASCII";
}
}
catch(SecurityException se)
{
encoding = "ASCII";
}
}
//this.m_encoding = encoding;
String javaEncoding = org.apache.xalan.serialize.Encodings.convertMime2JavaEncoding(encoding);
Writer w = new OutputStreamWriter( ostream, javaEncoding );
((ParserAdapter)handler).setContentHandler(new FormatterToText(w).getSerializerObject());
}
else if ( format.getMethod().equalsIgnoreCase( "xhtml" ) )
{
handler = new XMLSerializer(ostream, format);
//handler = Serializer.makeSAXSerializer(ostream, format);
}
else
{
handler = new XMLSerializer(ostream, format);
//handler = Serializer.makeSAXSerializer(ostream, format);
}
}
if(null == handler)
{
String method = props.getProperty(OutputKeys.METHOD);
org.apache.xml.serialize.SerializerFactory factory = org.apache.xml.serialize.SerializerFactory.getSerializerFactory(method);
org.apache.xml.serialize.Serializer serializer = factory.makeSerializer(ostream, format);
handler = serializer.asDocumentHandler();
}
return handler;
}