Package org.dom4j

Examples of org.dom4j.Attribute


            element.addAttribute(attribute, "false");
        }
    }

    public static boolean getAttributeAsBoolean(Element element, String attributeName, boolean defaultValue) {
        Attribute attribute = element.attribute(attributeName);
        if (attribute == null) {
            return defaultValue;
        }

        return "true".equals(attribute.getValue());
    }
View Full Code Here


        }
       
        // add attributes if present
        if (element.attributeCount() > 0) {
            for (int i = 0; i < element.attributeCount(); i++) {
                Attribute attr = element.attribute(i);
                int index = findNamespaceIndex(attr.getNamespace());
                m_xmlWriter.addAttribute(index, attr.getName(),
                     attr.getValue());
            }
        }
       
        // check for content present
        if (hascontent) {
View Full Code Here

  public void setAttribute(String name, String value) throws DOMException {
    addAttribute(name, value);
  }

  public void removeAttribute(String name) throws DOMException {
    Attribute attribute = attribute(name);

    if (attribute != null) {
      remove(attribute);
    }
  }
View Full Code Here

    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();
      }
View Full Code Here

    return DOMNodeHelper.asDOMAttr(attribute);
  }

  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");
View Full Code Here

          "No such attribute");
    }
  }

  public String getAttributeNS(String namespaceURI, String localName) {
    Attribute attribute = attribute(namespaceURI, localName);

    if (attribute != null) {
      String answer = attribute.getValue();

      if (answer != null) {
        return answer;
      }
    }
View Full Code Here

    return "";
  }

  public void setAttributeNS(String namespaceURI, String qualifiedName,
                             String value) throws DOMException {
    Attribute attribute = attribute(namespaceURI, qualifiedName);

    if (attribute != null) {
      attribute.setValue(value);
    } else {
      QName qname = getQName(namespaceURI, qualifiedName);
      addAttribute(qname, value);
    }
  }
View Full Code Here

    }
  }

  public void removeAttributeNS(String namespaceURI, String localName)
      throws DOMException {
    Attribute attribute = attribute(namespaceURI, localName);

    if (attribute != null) {
      remove(attribute);
    }
  }
View Full Code Here

    }
  }

  public org.w3c.dom.Attr getAttributeNodeNS(String namespaceURI,
                                             String localName) {
    Attribute attribute = attribute(namespaceURI, localName);

    if (attribute != null) {
      DOMNodeHelper.asDOMAttr(attribute);
    }
View Full Code Here

    return null;
  }

  public org.w3c.dom.Attr setAttributeNodeNS(org.w3c.dom.Attr newAttr)
      throws DOMException {
    Attribute attribute = attribute(newAttr.getNamespaceURI(), newAttr
        .getLocalName());

    if (attribute != null) {
      attribute.setValue(newAttr.getValue());
    } else {
      attribute = createAttribute(newAttr);
      add(attribute);
    }
View Full Code Here

TOP

Related Classes of org.dom4j.Attribute

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.