WMLRootConfiguration wmlConfiguration,
WBSAXProcessorContext processorContext,
WBSAXContentHandler handler
) throws IOException, ProtocolException {
URLOptimiser optimiser;
WBSAXContentHandler filter;
if (logger.isDebugEnabled()) {
logger.debug("Using dissection");
}
// Set up the dissection element processors.
wbsaxOutputter.addSpecialElementProcessor(
DissectionConstants.DISSECTABLE_CONTENTS_ELEMENT,
new WBSAXDissectionElementProcessor(processorContext,
DissectionElementTypes.getDissectableAreaType()));
wbsaxOutputter.addSpecialElementProcessor(
DissectionConstants.KEEPTOGETHER_ELEMENT,
new WBSAXDissectionElementProcessor(processorContext,
DissectionElementTypes.getKeepTogetherType()));
wbsaxOutputter.addSpecialElementProcessor(
DissectionConstants.SHARD_LINK_ELEMENT,
new WBSAXShardLinkElementProcessor(processorContext,
DissectionElementTypes.getShardLinkType()));
wbsaxOutputter.addSpecialElementProcessor(
DissectionConstants.SHARD_LINK_GROUP_ELEMENT,
new WBSAXDissectionElementProcessor(processorContext,
DissectionElementTypes.getShardLinkGroupType()));
wbsaxOutputter.addSpecialElementProcessor(
DissectionConstants.SHARD_LINK_CONDITIONAL_ELEMENT,
new WBSAXDissectionElementProcessor(processorContext,
DissectionElementTypes.getShardLinkConditionalType()));
// Factory to create dissection WBDOM nodes.
DissectableWBDOMFactory dissectionFactory =
new DissectableWBDOMFactory(wmlConfiguration);
// Handler to parse WBSAX events into WBDOM nodes.
WBSAXParser parser = new DissectionWBSAXParser(dissectionFactory,
wmlConfiguration);
StringWriter out = null;
try {
if (logger.isDebugEnabled()) {
out = new StringWriter();
handler = new WBSAXDisassembler(parser, out);
} else {
handler = parser;
}
// Plugin optimiser
optimiser = new URLOptimiser(handler);
optimiser.setPageContext(getMarinerPageContext());
if (logger.isDebugEnabled()) {
out = new StringWriter();
filter = new WBSAXDisassembler(optimiser, out);
} else {
filter = optimiser;