Code example for Attr

Methods: getValuegetTextContentlookupNamespaceURI

0
     * @param attribute the attribute with a QName value 
     *  
     * @return a QName from an attributes value, or null if the given attribute is null 
     */ 
    public static QName getAttributeValueAsQName(final Attr attribute) {
        if (attribute == null || StringSupport.isNullOrEmpty(attribute.getValue())) {
            return null; 
        } 
 
        final String attributeValue = attribute.getTextContent();
        final String[] valueComponents = attributeValue.split(":");
        if (valueComponents.length == 1) {
            return QNameSupport.constructQName(attribute.lookupNamespaceURI(null), valueComponents[0], null);
        } else { 
            return QNameSupport.constructQName(attribute.lookupNamespaceURI(valueComponents[0]), valueComponents[1],
                    valueComponents[0]);
        } 
    } 
 
    /** 
Connect your IDE to all the code out there  Get Codota for Java