ContentHandler handler =
(org.w3c.dom.Node.DOCUMENT_FRAGMENT_NODE == type)
? new DOMBuilder(doc, (org.w3c.dom.DocumentFragment) outputNode)
: new DOMBuilder(doc, outputNode);
String encoding = format.getProperty(OutputKeys.ENCODING);
xoh = new ToXMLSAXHandler(handler, (LexicalHandler)handler, encoding);
}
else if (outputTarget instanceof SAXResult)
{
ContentHandler handler = ((SAXResult) outputTarget).getHandler();
if (null == handler)
throw new IllegalArgumentException(
"handler can not be null for a SAXResult");
LexicalHandler lexHandler;
if (handler instanceof LexicalHandler)
lexHandler = (LexicalHandler) handler;
else
lexHandler = null;
String encoding = format.getProperty(OutputKeys.ENCODING);
String method = format.getProperty(OutputKeys.METHOD);
if (org.apache.xml.serializer.Method.HTML.equals(method))
{
xoh = new ToHTMLSAXHandler(handler, lexHandler, encoding);
}
else if (org.apache.xml.serializer.Method.TEXT.equals(method))
{
xoh = new ToTextSAXHandler(handler, lexHandler, encoding);
}
else
{
ToXMLSAXHandler toXMLSAXHandler = new ToXMLSAXHandler(handler, lexHandler, encoding);
toXMLSAXHandler.setShouldOutputNSAttr(false);
xoh = toXMLSAXHandler;
}
String publicID = format.getProperty(OutputKeys.DOCTYPE_PUBLIC);