@Override public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { ModelReader8Handler.ElementHandler current = (myHandlersStack.empty() ? (ModelReader8Handler.ElementHandler) null : myHandlersStack.peek()); if (current == null) { // root current = modelhandler; } else { current = current.createChild(myValues.peek(), qName, attributes); } // check required for (String attr : current.requiredAttributes()) { if (attributes.getValue(attr) == null) { throw new SAXParseException("attribute " + attr + " is absent", null); } } Object result = current.createObject(attributes); if (myHandlersStack.empty()) { myResult = (ModelLoadResult) result; } // handle attributes for (int i = 0; i < attributes.getLength(); i++) { String name = attributes.getQName(i); String value = attributes.getValue(i); current.handleAttribute(result, name, value); } myHandlersStack.push(current); myValues.push(result); }