void parseEntityRef(boolean externalAllowed) throws java.lang.Exception
    {
        String name;

        name = readNmtoken(true);
        require(';');
        switch (getEntityType(name)) {
            case ENTITY_UNDECLARED:
                error("reference to undeclared entity", name, null);
                break;
            case ENTITY_INTERNAL:
                pushString(name, getEntityValue(name));
                break;
            case ENTITY_TEXT:
                if (externalAllowed) {
                    pushURL(name, getEntityPublicId(name),
                            getEntitySystemId(name), null, null, null);
                } else {
                    error("reference to external entity in attribute value.",
                            name, null);
                }
                break;
            case ENTITY_NDATA:
                if (externalAllowed) {
                    error("data entity reference in content", name, null);
                } else {
                    error("reference to external entity in attribute value.",
                            name, null);
                }
                break;
        }
    }