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

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

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

Element.removeAttributeNode介绍

[英]Removes the specified attribute node. If a default value for the removed Attr node is defined in the DTD, a new node immediately appears with the default value as well as the corresponding namespace URI, local name, and prefix when applicable. The implementation may handle default values from other schemas similarly but applications should use Document.normalizeDocument() to guarantee this information is up-to-date.
[中]删除指定的属性节点。如果在DTD中定义了删除的Attr节点的默认值,则会立即出现一个新节点,其中包含默认值以及相应的命名空间URI、本地名称和前缀(如果适用)。该实现可以类似地处理来自其他模式的默认值,但应用程序应使用Document.normalizeDocument()来确保此信息是最新的。

代码示例

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

private static void renameRenderedChildReference(Element element, String oldNodeName, String newNodeName) {
  Attr renderedChildReference = element.getAttributeNode("renderedChild");
  if (renderedChildReference == null) return;
  String oldRenderedChild = renderedChildReference.getValue();
  if (oldRenderedChild.equals(oldNodeName)) {
    if (newNodeName == null || newNodeName.length() == 0)
      element.removeAttributeNode(renderedChildReference);
    else
      renderedChildReference.setValue(newNodeName);
  }
}

代码示例来源:origin: spring-projects/spring-restdocs

if (node.getNodeType() == Node.ATTRIBUTE_NODE) {
  Attr attr = (Attr) node;
  attr.getOwnerElement().removeAttributeNode(attr);

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

@Override
public void remove() {
  if (last == null) {
    throw new IllegalStateException();
  }
  ((Element) context).removeAttributeNode(last);
}

代码示例来源:origin: org.xmlbeam/xmlprojector

/**
 * @param attributeNode
 */
public static void removeAttribute(final Attr attributeNode) {
  if (attributeNode == null) {
    return;
  }
  final Element owner = attributeNode.getOwnerElement();
  if (owner == null) {
    return;
  }
  owner.removeAttributeNode(attributeNode);
}

代码示例来源:origin: skynav/ttt

private static void normalizeDeclaration(Attr attr, Element elt, Map<String,String> normalizedPrefixes) {
  String nsUri = attr.getValue();
  String normalizedPrefix = normalizedPrefixes.get(nsUri);
  if (normalizedPrefix != null) {
    elt.removeAttributeNode(attr);
  }
}

代码示例来源:origin: fr.avianey.apache-xmlgraphics/batik

/**
 * Removes all the attributes from an element.
 *
 * @param element
 *            The given element
 */
private void removeAttributes(Element element) {
  NamedNodeMap oldNodeMap = element.getAttributes();
  int n = oldNodeMap.getLength();
  for (int i = n - 1; i >= 0; i--) {
    element.removeAttributeNode((Attr) oldNodeMap.item(i));
  }
}

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

/**
 * Removes all the attributes from an element.
 *
 * @param element
 *            The given element
 */
private void removeAttributes(Element element) {
  NamedNodeMap oldNodeMap = element.getAttributes();
  int n = oldNodeMap.getLength();
  for (int i = n - 1; i >= 0; i--) {
    element.removeAttributeNode((Attr) oldNodeMap.item(i));
  }
}

代码示例来源:origin: org.eclipse/org.eclipse.wst.xml.core

public void removeAttributes()
 {
  for (Iterator i = attributesToRemove.iterator(); i.hasNext(); )
  {
   Attr attr = (Attr)i.next();
   Element element = attr.getOwnerElement();
   if (element != null)
   {
    element.removeAttributeNode(attr);
   }
  }
 }   
}

代码示例来源:origin: pl.edu.icm.synat/synat-importer-direct

private void removeAttributes(Element element) {
  NamedNodeMap attributes = element.getAttributes();
  List<Attr> attributeNodes = new ArrayList<>();
  for(int i=0;i<attributes.getLength();i++){
    Node node = attributes.item(i);
    if (node instanceof Attr) {
      attributeNodes.add((Attr)node);
    }
  }
  for(Attr attr:attributeNodes){
    element.removeAttributeNode(attr);
  }
}

代码示例来源:origin: org.opensingular/form-core

/**
 * @see org.w3c.dom.Element#removeAttributeNode(Attr)
 */
public Attr removeAttributeNode(Attr arg0) throws DOMException {
  return getAtualInterno().removeAttributeNode(arg0);
}

代码示例来源:origin: org.opensingular/form-core

/**
 * @see org.w3c.dom.Element#removeAttributeNode(Attr)
 */
@Override
public Attr removeAttributeNode(Attr arg0) {
  return original.get().removeAttributeNode(arg0);
}

代码示例来源:origin: org.opensingular/singular-commons

/**
 * @see org.w3c.dom.Element#removeAttributeNode(Attr)
 */
@Override
public Attr removeAttributeNode(Attr arg0) {
  return original.get().removeAttributeNode(arg0);
}

代码示例来源:origin: com.google.code.xmltool/xmltool

public XMLTag deleteAttributes() {
  Attr[] attrs = attr(current);
  for (Attr attr : attrs) {
    current.removeAttributeNode(attr);
  }
  return this;
}

代码示例来源:origin: fbacchella/jrds

/**
 * @param oldAttr
 * @return
 * @throws org.w3c.dom.DOMException
 * @see org.w3c.dom.Element#removeAttributeNode(org.w3c.dom.Attr)
 */
public Attr removeAttributeNode(Attr oldAttr) {
  return getParent().removeAttributeNode(oldAttr);
}

代码示例来源:origin: org.opensingular/singular-commons

/**
 * @see org.w3c.dom.Element#removeAttributeNode(Attr)
 */
public Attr removeAttributeNode(Attr arg0) throws DOMException {
  return getCurrentInternal().removeAttributeNode(arg0);
}

代码示例来源:origin: org.eclipse/org.eclipse.wst.xsd.ui

public void execute()
{
  super.execute();
  hostElement.removeAttributeNode(attr);
}

代码示例来源:origin: Geomatys/geotoolkit

@Override
public Attr removeAttributeNode(Attr oldAttr) throws DOMException {
  final Element elem = getElement();
  return elem != null ? elem.removeAttributeNode(oldAttr) : null;
}

代码示例来源:origin: GeeQuery/ef-orm

/**
 * 清除元素节点的所有属性
 * 
 * @param element
 *            要清除属性的节点
 */
public static void clearAttribute(Element element) {
  for (Node node : toArray(element.getAttributes())) {
    element.removeAttributeNode((Attr) node);
  }
}

代码示例来源:origin: org.apache.ws.commons.axiom/dom-testsuite

@Override
  protected void runTest() throws Throwable {
    Document document = dbf.newDocumentBuilder().newDocument();
    Element element = document.createElementNS(null, "test");
    Attr attr = mock(Attr.class);
    try {
      element.removeAttributeNode(attr);
      fail("Expected DOMException");
    } catch (DOMException ex) {
      assertThat(ex.code).isEqualTo(DOMException.NOT_FOUND_ERR);
    }
  }
}

代码示例来源:origin: org.vx68k.quercus/quercus

public DOMAttr removeAttributeNode(DOMAttr oldAttr)
 throws DOMException
{
 try {
  return wrap(_delegate.removeAttributeNode(oldAttr._delegate));
 }
 catch (org.w3c.dom.DOMException ex) {
  throw wrap(ex);
 }
}

相关文章

微信公众号

最新文章

更多