Code example for Attr

Methods: setValue

0
        Assert.isNotNull(attributeName, "Attribute name may not be null");
        Assert.isNotNull(attributeValue, "Attribute value may not be null");
 
        final Document document = element.getOwnerDocument();
        final Attr attribute = constructAttribute(document, attributeName);
        attribute.setValue(attributeValue);
        element.setAttributeNodeNS(attribute);
        if (isIDAttribute) {
            element.setIdAttributeNode(attribute, true);
        } 
    } 
 
    /** 
     * Adds an attribute to the given element. The value of the attribute is the instant now + the given duration 
     * expressed in XML dateTime format. 
     *  
     * @param element element to which the attribute will be added, not null 
     * @param attributeName name of the attribute, not null 
     * @param duration duration, in milliseconds, must be greater than 0 
     */ 
    public static void appendDateTimeAttribute(final Element element, QName attributeName, long duration) {