@Override
    public void startElement(String uri, String localName, String n,
            Attributes atts) throws SAXException {
        if (inHeadDepth >= 1) {
            inHeadDepth++;
            if ("http://www.w3.org/1999/xhtml" == uri) {
                if ("base" == localName) {
                    String href = atts.getValue("", "href");
                    if (href != null) {
                        installBase(href);
                    }
                } else if ("meta" == localName) {
                    String httpEquiv = atts.getValue("", "http-equiv");
                    if (equalsIgnoreAsciiCase("content-language", httpEquiv)) {
                        String content = atts.getValue("", "content");
                        if (content == null) {
                            content = "";
                        }
                        installContentLanguage(content);
                    }
                }
            }
        } else if (inHeadDepth == -1) {
            if ("html" == localName && "http://www.w3.org/1999/xhtml" == uri) {
                inHeadDepth = 0;
            } else {
                inHeadDepth = -2;
            }
        } else if (inHeadDepth == 0 && inCruftDepth == 0) {
            if ("head" == localName && "http://www.w3.org/1999/xhtml" == uri) {
                inHeadDepth = 1;
            } else {
                inCruftDepth = 1;
            }
        }

        String base = null;
        String lang = null;
        Direction dir = Direction.INHERIT;
        int len = atts.getLength();
        for (int i = 0; i < len; i++) {
            String ns = atts.getURI(i);
            if ("http://www.w3.org/XML/1998/namespace" == ns) {
                String name = atts.getLocalName(i);
                if ("lang" == name) {
                    lang = atts.getValue(i);
                } else if ("base" == name) {
                    base = atts.getValue(i);
                }
            } else if ("" == ns) {
                String name = atts.getLocalName(i);
                if (("dir" == name && "http://www.w3.org/1999/xhtml" == uri)
                        || ("direction" == name && "http://www.w3.org/2000/svg" == uri)) {
                    String value = atts.getValue(i);
                    if (equalsIgnoreAsciiCase("ltr", value)) {
                        dir = Direction.LTR;
                    } else if (equalsIgnoreAsciiCase("rtl", value)) {
                        dir = Direction.RTL;
                    }
                }
            }
        }
        push(base, lang, dir);
    }
@see nu.validator.xml.UriLangContext#toAbsoluteUriWithCurrentBase(java.lang.String)
src/nu/validator/xml/BaseUriTracker.java