org.jdom.Namespace.getNamespace()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(7.6k)|赞(0)|评价(0)|浏览(182)

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

Namespace.getNamespace介绍

[英]This will retrieve (if in existence) or create (if not) a Namespace for the supplied URI, and make it usable as a default namespace, as no prefix is supplied.
[中]这将为提供的URI检索(如果存在)或创建(如果不存在)一个Namespace,并使其可用作默认名称空间,因为没有提供前缀。

代码示例

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

/**
 * Registers an XML namespace with this node list. Once registered, you can
 * refer to the registered namespace using its prefix in the
 * {@link #get(String)} method from this node list and all other
 * node lists that are derived from this node list. Use the
 * <tt>nodelist["prefix:localname"]</tt> or the
 * <tt>nodelist["@prefix:localname"]</tt> syntax to reach elements and
 *  attributes whose names are namespace-scoped. Note that the namespace
 * prefix need not match the actual prefix used by the XML document itself
 * since namespaces are compared solely by their URI. You can also register
 * namespaces during template evaluation using the
 * <tt>nodelist._registerNamespace(prefix, uri)</tt> syntax in the template.
 * This mechanism is completely independent from the namespace declarations
 * in the XML document itself; its purpose is to give you an easy way
 * to refer to namespace-scoped elements in {@link #get(String)} and
 * in XPath expressions passed to {@link #exec(List)}. Note also that
 * the namespace prefix registry is shared among all node lists that
 * are created from a single node list - modifying the registry in one
 * affects all others as well. If you want to obtain a namespace 
 * "detached" copy of the node list, use the <code>_copy</code> key on
 * it (or call <code>nodeList.get("_copy")</code> directly from your
 * Java code. The returned node list has all the namespaces that the
 * original node list has, but they can be manipulated independently
 * thereon.
 */
public void registerNamespace(String prefix, String uri) {
  synchronized (namespaces) {
    namespaces.put(prefix, Namespace.getNamespace(prefix, uri));
  }
}

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

@Override
void getChildren(Object node, String localName, String namespaceUri, List result) {
  if (node instanceof Element) {
    Element e = (Element) node;
    if (localName == null) {
      result.addAll(e.getChildren());
    } else {
      result.addAll(e.getChildren(localName, Namespace.getNamespace("", namespaceUri)));
    }
  } else if (node instanceof Document) {
    Element root = ((Document) node).getRootElement();
    if (localName == null || (equal(root.getName(), localName) && equal(root.getNamespaceURI(), namespaceUri))) {
      result.add(root);
    }
  }
}

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

return node.getChildren(localName).iterator();
return node.getChildren(localName, Namespace.getNamespace(namespacePrefix, namespaceURI)).iterator();
  if (!Namespace.getNamespace(namespacePrefix, namespaceURI).equals(el.getNamespace())) {
    return JaxenConstants.EMPTY_ITERATOR;

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

/**
 * Retrieves an <code>Iterator</code> over the attribute elements that
 * match the supplied name.
 *
 * @param contextNode      the origin context node
 * @param localName        the local name of the attributes to return, always present
 * @param namespacePrefix  the prefix of the namespace of the attributes to return
 * @param namespaceURI     the URI of the namespace of the attributes to return
 * @return an Iterator     that traverses the named attributes, not null
 */
public Iterator getAttributeAxisIterator(
    Object contextNode, String localName, String namespacePrefix, String namespaceURI) {
  if ( contextNode instanceof Element ) {
    Element node = (Element) contextNode;
    Namespace namespace = (namespaceURI == null ? Namespace.NO_NAMESPACE : 
                Namespace.getNamespace(namespacePrefix, namespaceURI));
    Attribute attr = node.getAttribute(localName, namespace);
    if (attr != null) {
      return new SingleObjectIterator(attr);
    }
  }
  return JaxenConstants.EMPTY_ITERATOR;
}

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

result.addAll(e.getAttributes());
} else {
  Attribute attr = e.getAttribute(localName, Namespace.getNamespace("", namespaceUri)); 
  if (attr != null) {
    result.add(attr);

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

/**
 * Returns the namespace used by RSS elements in document of the RSS 1.0
 * <P>
 *
 * @return returns "http://purl.org/rss/1.0/".
 */
protected Namespace getRSSNamespace() {
  return Namespace.getNamespace(RSS_URI);
}

代码示例来源:origin: apache/oozie

@Override
  protected Namespace getSectionNamespace(){
    return Namespace.getNamespace("uri:oozie:hive-action:0.5");
  }
}

代码示例来源:origin: org.apache.oozie/oozie-core

@Override
  protected Namespace getSectionNamespace(){
    return Namespace.getNamespace("uri:oozie:hive-action:0.5");
  }
}

代码示例来源:origin: org.rometools/rome-modules

/**
 * Returns the namespace used by RSS elements in document of the RSS 1.0
 * <P>
 *
 * @return returns "http://purl.org/rss/1.0/".
 */
protected Namespace getRSSNamespace() {
  return Namespace.getNamespace(RSS_URI);
}

代码示例来源:origin: rome/modules

/**
 * Returns the namespace used by RSS elements in document of the RSS 1.0
 * <P>
 *
 * @return returns "http://purl.org/rss/1.0/".
 */
protected Namespace getRSSNamespace() {
  return Namespace.getNamespace(RSS_URI);
}

代码示例来源:origin: apache/oozie

public static Element getSLAElement(Element elem) {
  Element eSla_1 = elem.getChild("info", Namespace.getNamespace(SchemaService.SLA_NAME_SPACE_URI));
  Element eSla_2 = elem.getChild("info", Namespace.getNamespace(SchemaService.SLA_NAMESPACE_URI_2));
  return (eSla_2 != null) ? eSla_2 : eSla_1;
}

代码示例来源:origin: org.n52.wps/52n-wps-configuration-api

private Element getElement(Element element, String child) {
  if (element != null) {
    return element.getChild(child, Namespace.getNamespace(NAMESPACE));
  }
  return null;
}

代码示例来源:origin: org.jdom/jdom-legacy

private void readObject(ObjectInputStream in)
      throws IOException, ClassNotFoundException {

    in.defaultReadObject();

    Object prefix = in.readObject();
    Object uri = in.readObject();

    if (prefix != null) {  // else leave namespace null here
      namespace = Namespace.getNamespace((String) prefix, (String) uri);
    }
  }
}

代码示例来源:origin: org.codehaus.xfire/xfire-core

protected void removeImports(Element schema)
{
  List children = schema.getChildren("import", Namespace.getNamespace(SoapConstants.XSD));
  
  for (Iterator sitr = children.iterator(); sitr.hasNext();)
  {
    sitr.next();
    sitr.remove();
  }
}

代码示例来源:origin: edu.ucar/opendap

/**
 * Constructs a new <code>DDSXMLParser</code>.
 * The OPeNDAP namespace is defined during the construction
 * of an instance of this class.
 */
public DDSXMLParser(String nameSpace) {
  super();
  opendapNameSpace = Namespace.getNamespace(nameSpace);
  lastDoc = null;
  _Debug = Debug.isSet("DDSXMLParser");
}

代码示例来源:origin: org.codehaus.xfire/xfire-core

public void writeDefaultNamespace(String namespace)
  throws XMLStreamException
{
  currentNode.addNamespaceDeclaration(Namespace.getNamespace("", namespace));
}

代码示例来源:origin: org.n52.wps/52n-wps-configuration-api

private String getValue(Element element, String child) {
  if (element != null) {
    Element childElement = element.getChild(child, Namespace.getNamespace(NAMESPACE));
    if (childElement != null) {
      return childElement.getValue();
    }
  }
  return null;
}

代码示例来源:origin: org.codehaus.xfire/xfire-core

public void writeAttribute(String prefix, String namespace, String local, String value)
  throws XMLStreamException
{
  currentNode.setAttribute(new Attribute(local, value, Namespace.getNamespace(prefix,
                                        namespace)));
}

代码示例来源:origin: apache/cxf

public void writeNamespace(String prefix, String namespace) throws XMLStreamException {
  Namespace decNS = currentNode.getNamespace(prefix);
  if (decNS == null || !decNS.getURI().equals(namespace)) {
    currentNode.addNamespaceDeclaration(Namespace.getNamespace(prefix, namespace));
  }
}

代码示例来源:origin: org.apache.cxf/cxf-rt-databinding-aegis

public void writeNamespace(String prefix, String namespace) throws XMLStreamException {
  Namespace decNS = currentNode.getNamespace(prefix);
  if (decNS == null || !decNS.getURI().equals(namespace)) {
    currentNode.addNamespaceDeclaration(Namespace.getNamespace(prefix, namespace));
  }
}

相关文章