}
} else {
// Calculate the depth of the element to be discarded. This determines how many
// END_ELEMENT events we need to consume.
int targetDepth = elementLevel-1;
OMContainerEx current = target;
while (current != container) {
if (current instanceof OMElement) {
targetDepth--;
current = (OMContainerEx)((OMElement)current).getParent();
} else {
throw new OMException("Called discard for an element that is not being built by this builder");
}
}
while (elementLevel > targetDepth) {
parserNext();
}
}
// Mark nodes as discarded
OMContainerEx current = target;
while (true) {
discarded(current);
if (current == container) {
break;
}