public static String getAttributeValue(final Node elementNode, final String attrName, final String defValue)
    {
        if (null == elementNode)
        {
            throw new IllegalStateException(
                "element node is null when looking for attribute: " + attrName);
        }

        final NamedNodeMap attributes = elementNode.getAttributes();
        final Node attrNode = attributes.getNamedItemNS(null, attrName);
        if (null == attrNode)
        {
            return defValue;
        }

        return attrNode.getNodeValue();
    }
Helper function that uses a default value when value not set.

@param elementNode that should have the attribute.
@param attrName    that is to be looked up.
@param defValue    value to return if not set.
@return value of the attribute or defValue.
sbe-tool/src/main/java/uk/co/real_logic/sbe/xml/XmlSchemaParser.java