org.w3c.dom.Element.setAttributeNodeNS()方法的使用及代码示例

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

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

Element.setAttributeNodeNS介绍

[英]Adds a new attribute. If an attribute with that local name and that namespace URI is already present in the element, it is replaced by the new one. Replacing an attribute node by itself has no effect.
Per [XML Namespaces] , applications must use the value null as the namespaceURI parameter for methods if they wish to have no namespace.
[中]添加新属性。如果元素中已存在具有该本地名称和名称空间URI的属性,则该属性将被新属性替换。单独替换属性节点没有效果。
根据[{$0$}],如果应用程序希望没有命名空间,则必须将值null用作方法的namespaceURI参数。

代码示例

代码示例来源:origin: plutext/docx4j

protected void setLocalIdAttribute(String attrName, String value) {
  
  if (value != null) {
    Attr attr = getDocument().createAttributeNS(null, attrName);
    attr.setValue(value);
    getElement().setAttributeNodeNS(attr);
    getElement().setIdAttributeNode(attr, true);
  }
  else {
    getElement().removeAttributeNS(null, attrName);
  }
}

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

attr.setValue(attrValue);
element.setAttributeNodeNS(attr);
attr.setValue(attrValue);
element.setAttributeNode(attr);

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

a.setValue(attrs.getValue(i));
e.setAttributeNodeNS(a);

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

public void writeDefaultNamespace(String namespace) throws XMLStreamException {
  Attr attr = document.createAttributeNS(XML_NS, "xmlns");
  attr.setValue(namespace);
  ((Element)currentNode).setAttributeNodeNS(attr);
}

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

public void writeAttribute(String namespace, String local, String value) throws XMLStreamException {
  Attr a = document.createAttributeNS(namespace, local);
  a.setValue(value);
  ((Element)currentNode).setAttributeNodeNS(a);
}

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

public void writeAttribute(String namespace, String local, String value) throws XMLStreamException {
  Attr a = document.createAttributeNS(namespace, local);
  a.setValue(value);
  ((Element)currentNode).setAttributeNodeNS(a);
}

代码示例来源:origin: org.apache.cxf/cxf-api

public void writeDefaultNamespace(String namespace) throws XMLStreamException {
  Attr attr = document.createAttributeNS(XML_NS, "xmlns");
  attr.setValue(namespace);
  ((Element)currentNode).setAttributeNodeNS(attr);
}

代码示例来源:origin: org.apache.cxf/cxf-common-utilities

public void writeDefaultNamespace(String namespace) throws XMLStreamException {
  Attr attr = document.createAttributeNS(XML_NS, "xmlns");
  attr.setValue(namespace);
  ((Element)currentNode).setAttributeNodeNS(attr);
}

代码示例来源:origin: org.apache.cxf/cxf-api

public void writeAttribute(String namespace, String local, String value) throws XMLStreamException {
  Attr a = document.createAttributeNS(namespace, local);
  a.setValue(value);
  ((Element)currentNode).setAttributeNodeNS(a);
}

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

public void writeDefaultNamespace(String namespace) throws XMLStreamException {
  Attr attr = document.createAttributeNS(XML_NS, "xmlns");
  attr.setValue(namespace);
  ((Element)currentNode).setAttributeNodeNS(attr);
}

代码示例来源:origin: org.apache.cxf/cxf-bundle-jaxrs

public void writeAttribute(String namespace, String local, String value) throws XMLStreamException {
  Attr a = document.createAttributeNS(namespace, local);
  a.setValue(value);
  ((Element)currentNode).setAttributeNodeNS(a);
}

代码示例来源:origin: org.apache.cxf/cxf-bundle-jaxrs

public void writeDefaultNamespace(String namespace) throws XMLStreamException {
  Attr attr = document.createAttributeNS(XML_NS, "xmlns");
  attr.setValue(namespace);
  ((Element)currentNode).setAttributeNodeNS(attr);
}

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

public void writeAttribute(String prefix, String namespace, String local, String value)
  throws XMLStreamException
{
  if (prefix.length() > 0)
    local = prefix + ":" + local;
  
  Attr a = document.createAttributeNS(namespace, local);
  a.setValue(value);
  currentNode.setAttributeNodeNS(a);
}

代码示例来源:origin: org.metatype.sxc/sxc-runtime

public void writeAttribute(String prefix, String namespace, String local, String value)
  throws XMLStreamException {
  if (prefix.length() > 0) {
    local = prefix + ":" + local;
  }
  
  Attr a = document.createAttributeNS(namespace, local);
  a.setValue(value);
  currentNode.setAttributeNodeNS(a);
}

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

private static void declare(Element node, String uri, String prefix) {
  String qualname;
  if (prefix != null && prefix.length() > 0) {
    qualname = "xmlns:" + prefix;
  } else {
    qualname = "xmlns";
  }
  Attr attr = node.getOwnerDocument().createAttributeNS(XML_NS, qualname);
  attr.setValue(uri);
  node.setAttributeNodeNS(attr);
}
public static XMLStreamReader createXMLStreamReader(InputSource src) {

代码示例来源:origin: org.apache.neethi/neethi

private static void declare(Element node, String uri, String prefix) {
    String qualname;
    if (prefix != null && prefix.length() > 0) {
      qualname = "xmlns:" + prefix;
    } else {
      qualname = "xmlns";
    }
    Attr attr = node.getOwnerDocument().createAttributeNS("http://www.w3.org/2000/xmlns/", qualname);
    attr.setValue(uri);
    node.setAttributeNodeNS(attr);
  }
}

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

private static void declare(Element node, String uri, String prefix) {
  String qualname;
  if (prefix != null && prefix.length() > 0) {
    qualname = "xmlns:" + prefix;
  } else {
    qualname = "xmlns";
  }
  Attr attr = node.getOwnerDocument().createAttributeNS(XML_NS, qualname);
  attr.setValue(uri);
  node.setAttributeNodeNS(attr);
}
public static XMLStreamReader createXMLStreamReader(InputSource src) {

代码示例来源:origin: org.apache.cxf/cxf-api

private static void declare(Element node, String uri, String prefix) {
  String qualname;
  if (prefix != null && prefix.length() > 0) {
    qualname = "xmlns:" + prefix;
  } else {
    qualname = "xmlns";
  }
  Attr attr = node.getOwnerDocument().createAttributeNS(XML_NS, qualname);
  attr.setValue(uri);
  node.setAttributeNodeNS(attr);
}
public static XMLStreamReader createXMLStreamReader(InputSource src) {

代码示例来源:origin: org.apache.cxf/cxf-common-utilities

private static void declare(Element node, String uri, String prefix) {
  String qualname;
  if (prefix != null && prefix.length() > 0) {
    qualname = "xmlns:" + prefix;
  } else {
    qualname = "xmlns";
  }
  Attr attr = node.getOwnerDocument().createAttributeNS(XML_NS, qualname);
  attr.setValue(uri);
  node.setAttributeNodeNS(attr);
}
public static XMLStreamReader createXMLStreamReader(InputSource src) {

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

public void writeNamespace(String prefix, String namespace) throws XMLStreamException {
  if (prefix.isEmpty()) {
    writeDefaultNamespace(namespace);
  } else {
    Attr attr = document.createAttributeNS(XML_NS, "xmlns:" + prefix);
    attr.setValue(namespace);
    ((Element)currentNode).setAttributeNodeNS(attr);
  }
}

相关文章

微信公众号

最新文章

更多