private synchronized void doParse(String systemId, String publicId,
            Reader reader, InputStream stream, String encoding)
            throws java.lang.Exception
    {
        basePublicId = publicId;
        baseURI = systemId;
        baseReader = reader;
        baseInputStream = stream;

        initializeVariables();

        // Set the default entities here.
        setInternalEntity(intern("amp"), "&#38;");
        setInternalEntity(intern("lt"), "&#60;");
        setInternalEntity(intern("gt"), "&#62;");
        setInternalEntity(intern("apos"), "&#39;");
        setInternalEntity(intern("quot"), "&#34;");

        if (handler != null) {
            handler.startDocument();
        }

        pushURL("[document]", basePublicId, baseURI, baseReader,
                baseInputStream, encoding);

        parseDocument();

        if (handler != null) {
            handler.endDocument();
        }
        cleanupVariables();
    }