@Override
    public void startElement(String uri, String localName, String qName,
        Attributes attributes) throws SAXException {

        // If the SAX implementation does not provide the local name, the
        // qualified name should be used instead
        String name = localName.isEmpty() ? qName : localName;

        // Get current state
        DocumentHandlerState current = getCurrentState();

        // Handler for tag just read
        TagHandler handler;

        // If no stack, use root handler
        if (current == null) {

            // Validate element name
            if (!name.equals(rootElementName))
                throw new SAXException("Root element must be '" + rootElementName + "'");

            handler = root;
        }

        // Otherwise, get handler from parent
        else {
            TagHandler parent_handler = current.getTagHandler();
            handler = parent_handler.childElement(name);
        }

        // If no handler returned, the element was not expected
        if (handler == null)
            throw new SAXException("Unexpected element: '" + name + "'");

        // Initialize handler
        handler.init(attributes);

        // Append new element state to stack
        stack.addLast(new DocumentHandlerState(handler));

    }
Returns the current element state. The current element state is the
state of the element the parser is currently within.

@return The current element state.
guacamole-ext/src/main/java/org/apache/guacamole/xml/DocumentHandler.java