}
private static void fixRange(List<Object> paragraphs, String startElement,
String endElement) throws Exception {
RangeFinder rt = new RangeFinder(startElement, endElement);
new TraversalUtil(paragraphs, rt);
for (CTBookmark bm : rt.getStarts()) {
try {
// Can't just remove the object from the parent,
// since in the parent, it may be wrapped in a JAXBElement
List<Object> theList = null;
if (bm.getParent() instanceof List) {
theList = (List)bm.getParent(); // eg body.getContent()
} else {
theList = ((ContentAccessor)(bm.getParent())).getContent();
}
Object deleteMe = null;
for (Object ox : theList) {
if (XmlUtils.unwrap(ox).equals(bm)) {
deleteMe = ox;
break;
}
}
if (deleteMe!=null) {
theList.remove(deleteMe);
}
} catch (ClassCastException cce) {
log.error(cce.getMessage(), cce);
}
}
for (CTMarkupRange mr : rt.getEnds()) {
try {
// Can't just remove the object from the parent,
// since in the parent, it may be wrapped in a JAXBElement
List<Object> theList = null;
if (mr.getParent() instanceof List) {