private String retrieveAttributeValue(final StartElement element,final QName attributeQName,final boolean mandatory,final String xPath){
  Attribute attribute=element.getAttributeByName(attributeQName);
  if (attribute == null) {
    if (mandatory) {
      throw new IllegalStateException("Looking for value for " + xPath + " but not present - flagged as mandatory.");
    }
    return null;
  }
 else {
    return attribute.getValue();
  }
}

private String retrieveAttributeValue ( final StartElement element , final QName attributeQName , final boolean mandatory , final String xPath ) { Attribute attribute = element . getAttributeByName ( attributeQName ) ; if ( attribute == null ) { if ( mandatory ) { throw new IllegalStateException ( "Looking for value for " + xPath + " but not present - flagged as mandatory." ) ; } return null ; } else { return attribute . getValue ( ) ; } }
utility method to retrieve the value of an attribute . if the contents are mandatory , this method can throw a suitable exception if the contents are missing .
