// costly.
if(visitSequence == VisitSequence.BEFORE) {
// Register the targeting event...
if (eventListener != null) {
eventListener.onEvent(new ResourceTargetingEvent(element, config, VisitSequence.BEFORE));
}
DOMVisitBefore visitor = (DOMVisitBefore) configMap.getContentHandler();
try {
if (logger.isDebugEnabled()) {
logger.debug("Applying processing resource [" + config + "] to element [" + DomUtils.getXPath(element) + "] before applying resources to its child elements.");
}
visitor.visitBefore(element, executionContext);
if (eventListener != null) {
eventListener.onEvent(new ElementVisitEvent(element, configMap, VisitSequence.BEFORE));
}
} catch (Throwable e) {
String errorMsg = "Failed to apply processing unit [" + visitor.getClass().getName() + "] to [" + executionContext.getDocumentSource() + ":" + DomUtils.getXPath(element) + "].";
processVisitorException(element, e, configMap, VisitSequence.BEFORE, errorMsg);
}
} else if(visitSequence == VisitSequence.AFTER) {
// Register the targeting event...
if (eventListener != null) {
eventListener.onEvent(new ResourceTargetingEvent(element, config, VisitSequence.AFTER));
}
DOMVisitAfter visitor = (DOMVisitAfter) configMap.getContentHandler();
try {
if (logger.isDebugEnabled()) {
logger.debug("Applying processing resource [" + config + "] to element [" + DomUtils.getXPath(element) + "] after applying resources to its child elements.");
}
visitor.visitAfter(element, executionContext);
if (eventListener != null) {
eventListener.onEvent(new ElementVisitEvent(element, configMap, VisitSequence.AFTER));
}
} catch (Throwable e) {
String errorMsg = "Failed to apply processing unit [" + visitor.getClass().getName() + "] to [" + executionContext.getDocumentSource() + ":" + DomUtils.getXPath(element) + "].";
processVisitorException(element, e, configMap, VisitSequence.BEFORE, errorMsg);
}
} else if(visitSequence == VisitSequence.CLEAN) {
// Register the targeting event...
if (eventListener != null) {
eventListener.onEvent(new ResourceTargetingEvent(element, config, VisitSequence.CLEAN));
}
ContentHandler contentHandler = configMap.getContentHandler();
if(contentHandler instanceof VisitLifecycleCleanable) {
VisitLifecycleCleanable visitor = (VisitLifecycleCleanable) contentHandler;