void parseEntityDecl() throws java.lang.Exception
    {
        char c;
        boolean peFlag = false;
        String name, value, notationName, ids[];

        // Check for a parameter entity.
        requireWhitespace();
        if (tryRead('%')) {
            peFlag = true;
            requireWhitespace();
        }

        // Read the entity name, and prepend
        // '%' if necessary.
        name = readNmtoken(true);
        if (peFlag) {
            name = "%" + name;
        }

        // Read the entity value.
        requireWhitespace();
        c = readCh();
        unread(c);
        if (c == '"' || c == '\'') {
            // Internal entity.
            context = CONTEXT_ENTITYVALUE;
            value = readLiteral(LIT_CHAR_REF | LIT_PE_REF);
            context = CONTEXT_DTD;
            setInternalEntity(name, value);
        } else {
            // Read the external IDs
            ids = readExternalIds(false);
            if (ids[1] == null) {
                error("system identifer missing", name, null);
            }

            // Check for NDATA declaration.
            skipWhitespace();
            if (tryRead("NDATA")) {
                requireWhitespace();
                notationName = readNmtoken(true);
                setExternalDataEntity(name, ids[0], ids[1], notationName);
            } else {
                setExternalTextEntity(name, ids[0], ids[1]);
            }
        }

        // Finish the declaration.
        skipWhitespace();
        require('>');
    }