*/
public static Serializer switchSerializerIfHTML(
String ns, String localName, Properties props, Serializer oldSerializer)
throws TransformerException
{
Serializer newSerializer = oldSerializer;
if (((null == ns) || (ns.length() == 0))
&& localName.equalsIgnoreCase("html"))
{
// System.out.println("transformer.getOutputPropertyNoDefault(OutputKeys.METHOD): "+
// transformer.getOutputPropertyNoDefault(OutputKeys.METHOD));
// Access at level of hashtable to see if the method has been set.
if (null != getOutputPropertyNoDefault(OutputKeys.METHOD, props))
return newSerializer;
// Getting the output properties this way won't cause a clone of
// the properties.
Properties prevProperties = props;
// We have to make sure we get an output properties with the proper
// defaults for the HTML method. The easiest way to do this is to
// have the OutputProperties class do it.
OutputProperties htmlOutputProperties = new OutputProperties(Method.HTML);
htmlOutputProperties.copyFrom(prevProperties, true);
Properties htmlProperties = htmlOutputProperties.getProperties();
// try
{
if (null != oldSerializer)
{
Serializer serializer =
SerializerFactory.getSerializer(htmlProperties);
Writer writer = oldSerializer.getWriter();
if (null != writer)
serializer.setWriter(writer);
else
{
OutputStream os = serializer.getOutputStream();
if (null != os)
serializer.setOutputStream(os);
}
newSerializer = serializer;
}
}
// catch (java.io.IOException e)