public static String getAttributeValueOrNull(final Node elementNode, final String attrName)
    {
        if (null == elementNode)
        {
            return null;
        }

        final NamedNodeMap attributes = elementNode.getAttributes();
        if (null == attributes)
        {
            return null;
        }

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

        return attrNode.getNodeValue();
    }
Helper function that hides the null return from {@link org.w3c.dom.NamedNodeMap#getNamedItem(String)}.

@param elementNode that could be null.
@param attrName    that is to be looked up.
@return null or value of the attribute.
sbe-tool/src/main/java/uk/co/real_logic/sbe/xml/XmlSchemaParser.java