for (int i = 0, len = nl.getLength(); i < len; i++) { Element link = (Element) nl.item(i); if (!link.getAttribute("rel").equals("stylesheet")) { continue; } StylesheetInfo info = new StylesheetInfo(); info.setOrigin(StylesheetInfo.AUTHOR); String a = link.getAttribute("rel"); if (a.indexOf("alternate") != -1) { continue; } a = link.getAttribute("type"); if ("".equals(a)) { a = "text/css"; } info.setType(a); a = link.getAttribute("href"); info.setUri(a); a = link.getAttribute("media"); if ("".equals(a)) { a = "screen"; } info.setMedia(a); a = link.getAttribute("title"); info.setTitle(a); if (info.getType().equals("text/css")) { list.add(info);
if (nl != null) { for (int i = 0, len = nl.getLength(); i < len; i++) { Element link = (Element) nl.item(i); if (!link.getAttribute("rel").equals("stylesheet")) { continue; } StylesheetInfo info = new StylesheetInfo(); info.setOrigin(StylesheetInfo.AUTHOR); String a = link.getAttribute("rel"); if (a.indexOf("alternate") != -1) { continue; } a = link.getAttribute("type"); if ("".equals(a)) { a = "text/css"; } info.setType(a); a = link.getAttribute("href"); info.setUri(a); a = link.getAttribute("media"); if ("".equals(a)) { a = "screen"; } info.setMedia(a); a = link.getAttribute("title"); info.setTitle(a); if (info.getType().equals("text/css")) { list.add(info); }
    public StylesheetInfo[] getStylesheetLinks(org.w3c.dom.Document doc) {        List list = new ArrayList();        //get the processing-instructions (actually for XmlDocuments)        StylesheetInfo[] refs = super.getStylesheetLinks(doc);        list.addAll(java.util.Arrays.asList(refs));        //get the link elements        org.w3c.dom.NodeList nl = null;        Element html = doc.getDocumentElement();        Element head = findFirstChild(html, "head");        if (head != null) {            nl = head.getElementsByTagName("link");        }        for (int i = 0, len = nl.getLength(); i < len; i++) {            Element link = (Element) nl.item(i);            if (!link.getAttribute("rel").equals("stylesheet")) {                continue;            }            StylesheetInfo info = new StylesheetInfo();            info.setOrigin(StylesheetInfo.AUTHOR);            String a = link.getAttribute("rel");            if (a.indexOf("alternate") != -1) {                continue;            }//DON'T get alternate stylesheets            a = link.getAttribute("type");            if ("".equals(a)) {                a = "text/css";            }//HACK: is not entirely correct because default may be set by META tag or HTTP headers            info.setType(a);            a = link.getAttribute("href");            info.setUri(a);            a = link.getAttribute("media");            if ("".equals(a)) {                a = "screen";            }//the default in HTML            info.setMedia(a);            a = link.getAttribute("title");            info.setTitle(a);            if (info.getType().equals("text/css")) {                list.add(info);            }        }        refs = new StylesheetInfo[list.size()];        for (int i = 0; i < refs.length; i++) {            refs[i] = (StylesheetInfo) list.get(i);        }        return refs;    }