Exemple #1
0
  /**
   * Returns a list of elements with the given tag name belonging to the given namespace.
   *
   * @param namespaceURI the namespace URI of elements to look for
   * @param localName is either the local name of elements to look for or the special value "*",
   *     which matches all elements.
   * @return a live NodeList of found elements in the order they appear in the tree
   */
  @JsxFunction({@WebBrowser(FF), @WebBrowser(value = IE, minVersion = 11), @WebBrowser(CHROME)})
  public Object getElementsByTagNameNS(final Object namespaceURI, final String localName) {
    final String description =
        "Document.getElementsByTagNameNS('" + namespaceURI + "', '" + localName + "')";

    final String prefix;
    if (namespaceURI != null && !"*".equals(namespaceURI)) {
      prefix = XmlUtil.lookupPrefix(getPage().getDocumentElement(), Context.toString(namespaceURI));
    } else {
      prefix = null;
    }

    final HTMLCollection collection =
        new HTMLCollection(getDomNodeOrDie(), false, description) {
          @Override
          protected boolean isMatching(final DomNode node) {
            if (!localName.equals(node.getLocalName())) {
              return false;
            }
            if (prefix == null) {
              return true;
            }
            return true;
          }
        };

    return collection;
  }
Exemple #2
0
 /* 16:   */
 /* 17:   */ public String jsxFunction_lookupNamespaceURI(String prefix) /* 18:   */ {
   /* 19:46 */ return XmlUtil.lookupNamespaceURI(
       (DomElement) ((SimpleScriptable) this.element_).getDomNodeOrDie(), prefix);
   /* 20:   */ }