@Override
    public void startDocument() throws SAXException {
        request = getRequest();
        httpContentLangHeader = "";
        tld = "";
        htmlStartTagLocator = null;
        inBody = false;
        currentOpenElementsInDifferentLang = 0;
        currentOpenElementsWithSkipName = 0;
        nonWhitespaceCharacterCount = 0;
        elementContent = new StringBuilder();
        documentContent = new StringBuilder();
        htmlElementHasLang = false;
        htmlElementLangAttrValue = "";
        declaredLangCode = "";
        hasDir = false;
        dirAttrValue = "";
        documentContent.setLength(0);
        currentOpenElementsWithSkipName = 0;
        try {
            systemId = getDocumentLocator().getSystemId();
            if (systemId != null && systemId.startsWith("http")) {
                Host hostname = URL.parse(systemId).host();
                if (hostname != null) {
                    String host = hostname.toString();
                    tld = host.substring(host.lastIndexOf(".") + 1);
                }
            }
        } catch (GalimatiasParseException e) {
            throw new RuntimeException(e);
        }
    }
@see nu.validator.checker.Checker#startDocument()
src/nu/validator/checker/LanguageDetectingChecker.java