@Override public void startElement( String namespaceURI, String localName, String qualifiedName, Attributes attributes) throws SAXException { super.startElement(namespaceURI, localName, qualifiedName, attributes); // Parse locations in attributes // TODO: Method configurable. if (addParseLocationAttributes) { AttributeParseLocation pp = // moduleGenerated.newParseLocation(elementIdentifier); new new AttributeParseLocation( currentLine, currentColumn, currentLine = locator.getLineNumber(), currentColumn = locator.getColumnNumber()); ppStack.push(pp); } // parse location in elements ParseLocationElement ple = (ParseLocationElement) currentElement; ple.elementStartTagBeginningLine = currentLine; ple.elementStartTagBeginningColumn = currentColumn; ple.elementStartTagEndLine = (currentLine = locator.getLineNumber()); ple.elementStartTagEndColumn = (currentColumn = locator.getColumnNumber()); }
@Override public void endElement(String namespaceURI, String localName, String qName) throws SAXException { if (usingParseLocationElements) { ParseLocationElement ple = (ParseLocationElement) currentElement; ple.elementEndTagEndLine = currentLine = locator.getLineNumber(); ple.elementEndTagEndColumn = currentColumn = locator.getColumnNumber(); } else if (addParseLocationAttributes) { AttributeParseLocation pp = ppStack.pop(); pp.setElementEndTagEndLine(currentLine = locator.getLineNumber()); pp.setElementEndTagEndColumn(currentColumn = locator.getColumnNumber()); currentElement.addAttribute(XMLConstants.PARSELOCATION_DECORATION_QNAME, pp.toString()); } super.endElement(namespaceURI, localName, qName); }