Ejemplo n.º 1
0
  NodeList getElementsByTagNameNS(
      final Parent xshadow, final String namespaceURI, final String localName) {
    if (localName == null) {
      return EMPTYLIST;
    }
    if (namespaceURI == null) {
      return EMPTYLIST;
    }

    final boolean alluri = "*".equals(namespaceURI);
    final boolean allname = "*".equals(localName);

    final ArrayList<JElement> enodes = new ArrayList<JElement>();
    if (xshadow != null) {
      final Iterator<org.jdom2.Element> it = xshadow.getDescendants(Filters.element());

      org.jdom2.Element e = null;
      if (xshadow instanceof org.jdom2.Element) {
        e = (org.jdom2.Element) xshadow;
      } else {
        if (it.hasNext()) {
          e = it.next();
        }
      }
      while (e != null) {
        if ((allname || localName.equals(e.getName()))
            && (alluri || namespaceURI.equals(e.getNamespaceURI()))) {
          enodes.add(find(e));
        }
        e = it.hasNext() ? it.next() : null;
      }
    }
    return new JNodeList(enodes);
  }
Ejemplo n.º 2
0
  NodeList getElementsByTagName(final Parent xshadow, final String tagname) {
    if (tagname == null) {
      return EMPTYLIST;
    }
    final ArrayList<JElement> enodes = new ArrayList<JElement>();
    if (xshadow != null) {
      final Iterator<org.jdom2.Element> it = xshadow.getDescendants(Filters.element());

      org.jdom2.Element e = null;
      if (xshadow instanceof org.jdom2.Element) {
        e = (org.jdom2.Element) xshadow;
      } else {
        if (it.hasNext()) {
          e = it.next();
        }
      }
      while (e != null) {
        if ("*".equals(tagname) || tagname.equals(e.getQualifiedName())) {
          enodes.add(find(e));
        }
        e = it.hasNext() ? it.next() : null;
      }
    }
    return new JNodeList(enodes);
  }