org.dom4j.Attribute.detach()方法的使用及代码示例

x33g5p2x  于2022-01-15 转载在 其他  
字(8.9k)|赞(0)|评价(0)|浏览(84)

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

Attribute.detach介绍

暂无

代码示例

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

public org.w3c.dom.Attr removeAttributeNode(org.w3c.dom.Attr oldAttr)
    throws DOMException {
  Attribute attribute = attribute(oldAttr);
  if (attribute != null) {
    attribute.detach();
    return DOMNodeHelper.asDOMAttr(attribute);
  } else {
    throw new DOMException(DOMException.NOT_FOUND_ERR,
        "No such attribute");
  }
}

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

public org.w3c.dom.Attr setAttributeNode(org.w3c.dom.Attr newAttr)
    throws DOMException {
  if (this.isReadOnly()) {
    throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR,
        "No modification allowed");
  }
  Attribute attribute = attribute(newAttr);
  if (attribute != newAttr) {
    if (newAttr.getOwnerElement() != null) {
      throw new DOMException(DOMException.INUSE_ATTRIBUTE_ERR,
          "Attribute is already in use");
    }
    Attribute newAttribute = createAttribute(newAttr);
    if (attribute != null) {
      attribute.detach();
    }
    add(newAttribute);
  }
  return DOMNodeHelper.asDOMAttr(attribute);
}

代码示例来源:origin: com.atlassian.plugins/atlassian-plugins-core

public void visit(Attribute node) {
  if (node.toString().contains("xmlns") || node.toString().contains("xsi:")) {
    node.detach();
  }
}

代码示例来源:origin: alibaba/PelicanDT

@Override
public void deleteAttribute(Node node, String attriName) {
  if (null == node || StringUtils.isBlank(attriName)) {
    log.warn("node is null or attrName is blank, operation skip");
  } else if (node instanceof Element) {
    Attribute attri = ((Element) node).attribute(attriName);
    if (null != attri) {
      attri.detach();
    }
  }
}

代码示例来源:origin: alibaba/PelicanDT

@Override
public void deleteAttribute(Node node, String attriName, String attriValue) {
  if (null == node || StringUtils.isBlank(attriName)) {
    log.warn("node is null or attrName is blank, operation skip");
  } else if (node instanceof Element) {
    //如果属性值为null,则设置为空字符串
    if (attriValue == null) {
      attriValue = "";
    }
    Attribute attri = ((Element) node).attribute(attriName);
    if ((null != attri) && attri.getValue().equals(attriValue)) {
      attri.detach();
    }
  }
}

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

public org.w3c.dom.Attr removeAttributeNode(org.w3c.dom.Attr oldAttr)
    throws DOMException {
  Attribute attribute = attribute(oldAttr);
  if (attribute != null) {
    attribute.detach();
    return DOMNodeHelper.asDOMAttr(attribute);
  } else {
    throw new DOMException(DOMException.NOT_FOUND_ERR,
        "No such attribute");
  }
}

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

public org.w3c.dom.Attr removeAttributeNode(org.w3c.dom.Attr oldAttr)
    throws DOMException {
  Attribute attribute = attribute(oldAttr);
  if (attribute != null) {
    attribute.detach();
    return DOMNodeHelper.asDOMAttr(attribute);
  } else {
    throw new DOMException(DOMException.NOT_FOUND_ERR,
        "No such attribute");
  }
}

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

public org.w3c.dom.Attr removeAttributeNode(org.w3c.dom.Attr oldAttr)
    throws DOMException {
  Attribute attribute = attribute(oldAttr);
  if (attribute != null) {
    attribute.detach();
    return DOMNodeHelper.asDOMAttr(attribute);
  } else {
    throw new DOMException(DOMException.NOT_FOUND_ERR,
        "No such attribute");
  }
}

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

public org.w3c.dom.Attr removeAttributeNode(org.w3c.dom.Attr oldAttr)
    throws DOMException {
  Attribute attribute = attribute(oldAttr);
  if (attribute != null) {
    attribute.detach();
    return DOMNodeHelper.asDOMAttr(attribute);
  } else {
    throw new DOMException(DOMException.NOT_FOUND_ERR,
        "No such attribute");
  }
}

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

public org.w3c.dom.Attr removeAttributeNode(org.w3c.dom.Attr oldAttr)
    throws DOMException {
  Attribute attribute = attribute(oldAttr);
  if (attribute != null) {
    attribute.detach();
    return DOMNodeHelper.asDOMAttr(attribute);
  } else {
    throw new DOMException(DOMException.NOT_FOUND_ERR,
        "No such attribute");
  }
}

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

public org.w3c.dom.Attr removeAttributeNode(org.w3c.dom.Attr oldAttr)
    throws DOMException {
  Attribute attribute = attribute(oldAttr);
  if (attribute != null) {
    attribute.detach();
    return DOMNodeHelper.asDOMAttr(attribute);
  } else {
    throw new DOMException(DOMException.NOT_FOUND_ERR,
        "No such attribute");
  }
}

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

public org.w3c.dom.Attr removeAttributeNode(org.w3c.dom.Attr oldAttr)
    throws DOMException {
  Attribute attribute = attribute(oldAttr);
  if (attribute != null) {
    attribute.detach();
    return DOMNodeHelper.asDOMAttr(attribute);
  } else {
    throw new DOMException(DOMException.NOT_FOUND_ERR,
        "No such attribute");
  }
}

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

public void set(Object target, Object value, SessionFactoryImplementor factory) 
throws HibernateException {
  Element owner = ( Element ) target;
  Attribute attribute = owner.attribute(attributeName);
  if (value==null) {
    if (attribute!=null) attribute.detach();
  }
  else {
    if (attribute==null) {
      owner.addAttribute(attributeName, "null");
      attribute = owner.attribute(attributeName);
    }
    propertyType.setToXMLNode(attribute, value, factory);
  }
}

代码示例来源:origin: jboss.jboss-embeddable-ejb3/hibernate-all

public void set(Object target, Object value, SessionFactoryImplementor factory) 
throws HibernateException {
  Element owner = ( Element ) target;
  Attribute attribute = owner.attribute(attributeName);
  if (value==null) {
    if (attribute!=null) attribute.detach();
  }
  else {
    if (attribute==null) {
      owner.addAttribute(attributeName, "null");
      attribute = owner.attribute(attributeName);
    }
    super.propertyType.setToXMLNode(attribute, value, factory);
  }
}

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

public org.w3c.dom.Attr setAttributeNode(org.w3c.dom.Attr newAttr)
    throws DOMException {
  if (this.isReadOnly()) {
    throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR,
        "No modification allowed");
  }
  Attribute attribute = attribute(newAttr);
  if (attribute != newAttr) {
    if (newAttr.getOwnerElement() != null) {
      throw new DOMException(DOMException.INUSE_ATTRIBUTE_ERR,
          "Attribute is already in use");
    }
    Attribute newAttribute = createAttribute(newAttr);
    if (attribute != null) {
      attribute.detach();
    }
    add(newAttribute);
  }
  return DOMNodeHelper.asDOMAttr(attribute);
}

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

public org.w3c.dom.Attr setAttributeNode(org.w3c.dom.Attr newAttr)
    throws DOMException {
  if (this.isReadOnly()) {
    throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR,
        "No modification allowed");
  }
  Attribute attribute = attribute(newAttr);
  if (attribute != newAttr) {
    if (newAttr.getOwnerElement() != null) {
      throw new DOMException(DOMException.INUSE_ATTRIBUTE_ERR,
          "Attribute is already in use");
    }
    Attribute newAttribute = createAttribute(newAttr);
    if (attribute != null) {
      attribute.detach();
    }
    add(newAttribute);
  }
  return DOMNodeHelper.asDOMAttr(attribute);
}

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

public org.w3c.dom.Attr setAttributeNode(org.w3c.dom.Attr newAttr)
    throws DOMException {
  if (this.isReadOnly()) {
    throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR,
        "No modification allowed");
  }
  Attribute attribute = attribute(newAttr);
  if (attribute != newAttr) {
    if (newAttr.getOwnerElement() != null) {
      throw new DOMException(DOMException.INUSE_ATTRIBUTE_ERR,
          "Attribute is already in use");
    }
    Attribute newAttribute = createAttribute(newAttr);
    if (attribute != null) {
      attribute.detach();
    }
    add(newAttribute);
  }
  return DOMNodeHelper.asDOMAttr(attribute);
}

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

public org.w3c.dom.Attr setAttributeNode(org.w3c.dom.Attr newAttr)
    throws DOMException {
  if (this.isReadOnly()) {
    throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR,
        "No modification allowed");
  }
  Attribute attribute = attribute(newAttr);
  if (attribute != newAttr) {
    if (newAttr.getOwnerElement() != null) {
      throw new DOMException(DOMException.INUSE_ATTRIBUTE_ERR,
          "Attribute is already in use");
    }
    Attribute newAttribute = createAttribute(newAttr);
    if (attribute != null) {
      attribute.detach();
    }
    add(newAttribute);
  }
  return DOMNodeHelper.asDOMAttr(attribute);
}

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

public org.w3c.dom.Attr setAttributeNode(org.w3c.dom.Attr newAttr)
    throws DOMException {
  if (this.isReadOnly()) {
    throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR,
        "No modification allowed");
  }
  Attribute attribute = attribute(newAttr);
  if (attribute != newAttr) {
    if (newAttr.getOwnerElement() != null) {
      throw new DOMException(DOMException.INUSE_ATTRIBUTE_ERR,
          "Attribute is already in use");
    }
    Attribute newAttribute = createAttribute(newAttr);
    if (attribute != null) {
      attribute.detach();
    }
    add(newAttribute);
  }
  return DOMNodeHelper.asDOMAttr(attribute);
}

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

public org.w3c.dom.Attr setAttributeNode(org.w3c.dom.Attr newAttr)
    throws DOMException {
  if (this.isReadOnly()) {
    throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR,
        "No modification allowed");
  }
  Attribute attribute = attribute(newAttr);
  if (attribute != newAttr) {
    if (newAttr.getOwnerElement() != null) {
      throw new DOMException(DOMException.INUSE_ATTRIBUTE_ERR,
          "Attribute is already in use");
    }
    Attribute newAttribute = createAttribute(newAttr);
    if (attribute != null) {
      attribute.detach();
    }
    add(newAttribute);
  }
  return DOMNodeHelper.asDOMAttr(attribute);
}

相关文章