public void endElement(String namespaceURI, String localName, String raw)
throws SAXException {
Event start = (Event) stack.pop();
Event newEvent = null;
if (start instanceof Instruction) {
Instruction startInstruction = (Instruction) start;
EndInstruction endInstruction = new EndInstruction(locator,
startInstruction);
newEvent = endInstruction;
addEvent(newEvent);
startInstruction.endNotify();
} else {
StartElement startElement = (StartElement) start;
newEvent = new EndElement(locator, startElement);
startElement.setEndElement((EndElement) newEvent);
addEvent(newEvent);