org.dom4j.Element.getNamespaceForURI()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(9.0k)|赞(0)|评价(0)|浏览(178)

本文整理了Java中org.dom4j.Element.getNamespaceForURI()方法的一些代码示例,展示了Element.getNamespaceForURI()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Element.getNamespaceForURI()方法的具体详情如下:
包路径:org.dom4j.Element
类名称:Element
方法名:getNamespaceForURI

Element.getNamespaceForURI介绍

[英]Returns the Namespace which is mapped to the given URI or null if it could not be found. If there is more than one Namespace mapped to the URI, which of them will be returned is undetermined.
[中]返回映射到给定URI的Namespace,如果找不到则返回null。如果有多个Namespace映射到URI,则将返回哪一个尚未确定。

代码示例

代码示例来源:origin: org.dom4j/dom4j

public String getNamespacePrefix(String uri) {
  Element parentElement = getParent();
  if (parentElement != null) {
    Namespace namespace = parentElement.getNamespaceForURI(uri);
    if (namespace != null) {
      return namespace.getPrefix();
    }
  }
  return null;
}

代码示例来源:origin: org.dom4j/dom4j

public Attribute createAttribute(Element owner, QName qname, String value) {
  if (autoLoadSchema && qname.equals(XSI_NO_SCHEMA_LOCATION)) {
    Document document = (owner != null) ? owner.getDocument() : null;
    loadSchema(document, value);
  } else if (autoLoadSchema && qname.equals(XSI_SCHEMA_LOCATION)) {
    Document document = (owner != null) ? owner.getDocument() : null;
    String uri = value.substring(0, value.indexOf(' '));
    Namespace namespace = owner.getNamespaceForURI(uri);
    loadSchema(document, value.substring(value.indexOf(' ') + 1),
        namespace);
  }
  return super.createAttribute(owner, qname, value);
}

代码示例来源:origin: org.dom4j/dom4j

public Namespace getNamespaceForURI(String uri) {
  if ((uri == null) || (uri.length() <= 0)) {
    return Namespace.NO_NAMESPACE;
  } else if (uri.equals(getNamespaceURI())) {
    return getNamespace();
  } else {
    final Object contentShadow = content;
    if (contentShadow instanceof List) {
      List<Node> list = (List<Node>) contentShadow;
      for (Node node : list) {
        if (node instanceof Namespace) {
          Namespace namespace = (Namespace) node;
          if (uri.equals(namespace.getURI())) {
            return namespace;
          }
        }
      }
    } else if (contentShadow instanceof Namespace) {
      Namespace namespace = (Namespace) contentShadow;
      if (uri.equals(namespace.getURI())) {
        return namespace;
      }
    }
    Element parent = getParent();
    if (parent != null) {
      return parent.getNamespaceForURI(uri);
    }
    return null;
  }
}

代码示例来源:origin: hibernate/hibernate

public Namespace getNamespaceForURI(String s) {
  return target().getNamespaceForURI( s );
}

代码示例来源:origin: dom4j/dom4j

public String getNamespacePrefix(String uri) {
  Element parentElement = getParent();
  if (parentElement != null) {
    Namespace namespace = parentElement.getNamespaceForURI(uri);
    if (namespace != null) {
      return namespace.getPrefix();
    }
  }
  return null;
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.dom4j

public String getNamespacePrefix(String uri) {
  Element parentElement = getParent();
  if (parentElement != null) {
    Namespace namespace = parentElement.getNamespaceForURI(uri);
    if (namespace != null) {
      return namespace.getPrefix();
    }
  }
  return null;
}

代码示例来源:origin: org.jenkins-ci.dom4j/dom4j

public String getNamespacePrefix(String uri) {
  Element parentElement = getParent();
  if (parentElement != null) {
    Namespace namespace = parentElement.getNamespaceForURI(uri);
    if (namespace != null) {
      return namespace.getPrefix();
    }
  }
  return null;
}

代码示例来源:origin: maven/dom4j

public String getNamespacePrefix(String uri) {
  Element parentElement = getParent();
  if (parentElement != null) {
    Namespace namespace = parentElement.getNamespaceForURI(uri);
    if (namespace != null) {
      return namespace.getPrefix();
    }
  }
  return null;
}

代码示例来源:origin: com.alibaba.citrus.tool/antx-autoexpand

public String getNamespacePrefix(String uri) {
  Element parentElement = getParent();
  if (parentElement != null) {
    Namespace namespace = parentElement.getNamespaceForURI(uri);
    if (namespace != null) {
      return namespace.getPrefix();
    }
  }
  return null;
}

代码示例来源:origin: org.dom4j/org.motechproject.org.dom4j

public String getNamespacePrefix(String uri) {
  Element parentElement = getParent();
  if (parentElement != null) {
    Namespace namespace = parentElement.getNamespaceForURI(uri);
    if (namespace != null) {
      return namespace.getPrefix();
    }
  }
  return null;
}

代码示例来源:origin: org.dom4j/com.springsource.org.dom4j

public String getNamespacePrefix(String uri) {
  Element parentElement = getParent();
  if (parentElement != null) {
    Namespace namespace = parentElement.getNamespaceForURI(uri);
    if (namespace != null) {
      return namespace.getPrefix();
    }
  }
  return null;
}

代码示例来源:origin: apache/servicemix-bundles

public String getNamespacePrefix(String uri) {
  Element parentElement = getParent();
  if (parentElement != null) {
    Namespace namespace = parentElement.getNamespaceForURI(uri);
    if (namespace != null) {
      return namespace.getPrefix();
    }
  }
  return null;
}

代码示例来源:origin: dom4j/dom4j

public Attribute createAttribute(Element owner, QName qname, String value) {
  if (autoLoadSchema && qname.equals(XSI_NO_SCHEMA_LOCATION)) {
    Document document = (owner != null) ? owner.getDocument() : null;
    loadSchema(document, value);
  } else if (autoLoadSchema && qname.equals(XSI_SCHEMA_LOCATION)) {
    Document document = (owner != null) ? owner.getDocument() : null;
    String uri = value.substring(0, value.indexOf(' '));
    Namespace namespace = owner.getNamespaceForURI(uri);
    loadSchema(document, value.substring(value.indexOf(' ') + 1),
        namespace);
  }
  return super.createAttribute(owner, qname, value);
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.dom4j

public Attribute createAttribute(Element owner, QName qname, String value) {
  if (autoLoadSchema && qname.equals(XSI_NO_SCHEMA_LOCATION)) {
    Document document = (owner != null) ? owner.getDocument() : null;
    loadSchema(document, value);
  } else if (autoLoadSchema && qname.equals(XSI_SCHEMA_LOCATION)) {
    Document document = (owner != null) ? owner.getDocument() : null;
    String uri = value.substring(0, value.indexOf(' '));
    Namespace namespace = owner.getNamespaceForURI(uri);
    loadSchema(document, value.substring(value.indexOf(' ') + 1),
        namespace);
  }
  return super.createAttribute(owner, qname, value);
}

代码示例来源:origin: org.jenkins-ci.dom4j/dom4j

public Attribute createAttribute(Element owner, QName qname, String value) {
  if (autoLoadSchema && qname.equals(XSI_NO_SCHEMA_LOCATION)) {
    Document document = (owner != null) ? owner.getDocument() : null;
    loadSchema(document, value);
  } else if (autoLoadSchema && qname.equals(XSI_SCHEMA_LOCATION)) {
    Document document = (owner != null) ? owner.getDocument() : null;
    String uri = value.substring(0, value.indexOf(' '));
    Namespace namespace = owner.getNamespaceForURI(uri);
    loadSchema(document, value.substring(value.indexOf(' ') + 1),
        namespace);
  }
  return super.createAttribute(owner, qname, value);
}

代码示例来源:origin: apache/servicemix-bundles

public Attribute createAttribute(Element owner, QName qname, String value) {
  if (autoLoadSchema && qname.equals(XSI_NO_SCHEMA_LOCATION)) {
    Document document = (owner != null) ? owner.getDocument() : null;
    loadSchema(document, value);
  } else if (autoLoadSchema && qname.equals(XSI_SCHEMA_LOCATION)) {
    Document document = (owner != null) ? owner.getDocument() : null;
    String uri = value.substring(0, value.indexOf(' '));
    Namespace namespace = owner.getNamespaceForURI(uri);
    loadSchema(document, value.substring(value.indexOf(' ') + 1),
        namespace);
  }
  return super.createAttribute(owner, qname, value);
}

代码示例来源:origin: org.dom4j/com.springsource.org.dom4j

public Attribute createAttribute(Element owner, QName qname, String value) {
  if (autoLoadSchema && qname.equals(XSI_NO_SCHEMA_LOCATION)) {
    Document document = (owner != null) ? owner.getDocument() : null;
    loadSchema(document, value);
  } else if (autoLoadSchema && qname.equals(XSI_SCHEMA_LOCATION)) {
    Document document = (owner != null) ? owner.getDocument() : null;
    String uri = value.substring(0, value.indexOf(' '));
    Namespace namespace = owner.getNamespaceForURI(uri);
    loadSchema(document, value.substring(value.indexOf(' ') + 1),
        namespace);
  }
  return super.createAttribute(owner, qname, value);
}

代码示例来源:origin: com.alibaba.citrus.tool/antx-autoexpand

public Attribute createAttribute(Element owner, QName qname, String value) {
  if (autoLoadSchema && qname.equals(XSI_NO_SCHEMA_LOCATION)) {
    Document document = (owner != null) ? owner.getDocument() : null;
    loadSchema(document, value);
  } else if (autoLoadSchema && qname.equals(XSI_SCHEMA_LOCATION)) {
    Document document = (owner != null) ? owner.getDocument() : null;
    String uri = value.substring(0, value.indexOf(' '));
    Namespace namespace = owner.getNamespaceForURI(uri);
    loadSchema(document, value.substring(value.indexOf(' ') + 1),
        namespace);
  }
  return super.createAttribute(owner, qname, value);
}

代码示例来源:origin: maven/dom4j

public Attribute createAttribute(Element owner, QName qname, String value) {
  if (autoLoadSchema && qname.equals(XSI_NO_SCHEMA_LOCATION)) {
    Document document = (owner != null) ? owner.getDocument() : null;
    loadSchema(document, value);
  } else if (autoLoadSchema && qname.equals(XSI_SCHEMA_LOCATION)) {
    Document document = (owner != null) ? owner.getDocument() : null;
    String uri = value.substring(0, value.indexOf(' '));
    Namespace namespace = owner.getNamespaceForURI(uri);
    loadSchema(document, value.substring(value.indexOf(' ') + 1),
        namespace);
  }
  return super.createAttribute(owner, qname, value);
}

代码示例来源:origin: dom4j/dom4j

protected void testNamespaceForURI(Document document) throws Exception {
  Element root = document.getRootElement();
  Namespace ns = root.getNamespaceForURI("http://www.w3.org/namespace/");
  assertNamespace(ns, "t", "http://www.w3.org/namespace/");
  Element element = root.elements().get(0);
  Namespace ns2 = element
      .getNamespaceForURI("http://www.w3.org/namespace/");
  assertNamespace(ns2, "t", "http://www.w3.org/namespace/");
  assertTrue("Same namespace instance returned", ns == ns2);
  log("found: " + ns.asXML());
}

相关文章

微信公众号

最新文章

更多

Element类方法