public void checkMessages(XMLFile messagesDoc) throws DocumentException {
  for (Iterator<Node> i=messagesDoc.xpathIterator("/MessageCollection/Detector"); i.hasNext(); ) {
    Node node=i.next();
    messagesDoc.checkAttribute(node,"class");
    messagesDoc.checkElement(node,"Details");
  }
  for (Iterator<Node> i=messagesDoc.xpathIterator("/MessageCollection/BugPattern"); i.hasNext(); ) {
    Node node=i.next();
    messagesDoc.checkAttribute(node,"type");
    messagesDoc.checkElement(node,"ShortDescription");
    messagesDoc.checkElement(node,"LongDescription");
    messagesDoc.checkElement(node,"Details");
  }
  for (Iterator<Node> i=messagesDoc.xpathIterator("/MessageCollection/BugCode"); i.hasNext(); ) {
    Node node=i.next();
    messagesDoc.checkAttribute(node,"abbrev");
    messagesDoc.checkNonEmptyText(node);
  }
  Set<String> describedDetectorsSet=messagesDoc.collectAttributes("/MessageCollection/Detector","class");
  checkDescribed("Bug detectors not described by Detector elements",messagesDoc,declaredDetectorsSet,describedDetectorsSet);
  Set<String> describedAbbrevsSet=messagesDoc.collectAttributes("/MessageCollection/BugCode","abbrev");
  checkDescribed("Abbreviations not described by BugCode elements",messagesDoc,declaredAbbrevsSet,describedAbbrevsSet);
}

public void checkMessages ( XMLFile messagesDoc ) throws DocumentException { for ( Iterator < Node > i = messagesDoc . xpathIterator ( "/MessageCollection/Detector" ) ; i . hasNext ( ) ; ) { Node node = i . next ( ) ; messagesDoc . checkAttribute ( node , "class" ) ; messagesDoc . checkElement ( node , "Details" ) ; } for ( Iterator < Node > i = messagesDoc . xpathIterator ( "/MessageCollection/BugPattern" ) ; i . hasNext ( ) ; ) { Node node = i . next ( ) ; messagesDoc . checkAttribute ( node , "type" ) ; messagesDoc . checkElement ( node , "ShortDescription" ) ; messagesDoc . checkElement ( node , "LongDescription" ) ; messagesDoc . checkElement ( node , "Details" ) ; } for ( Iterator < Node > i = messagesDoc . xpathIterator ( "/MessageCollection/BugCode" ) ; i . hasNext ( ) ; ) { Node node = i . next ( ) ; messagesDoc . checkAttribute ( node , "abbrev" ) ; messagesDoc . checkNonEmptyText ( node ) ; } Set < String > describedDetectorsSet = messagesDoc . collectAttributes ( "/MessageCollection/Detector" , "class" ) ; checkDescribed ( "Bug detectors not described by Detector elements" , messagesDoc , declaredDetectorsSet , describedDetectorsSet ) ; Set < String > describedAbbrevsSet = messagesDoc . collectAttributes ( "/MessageCollection/BugCode" , "abbrev" ) ; checkDescribed ( "Abbreviations not described by BugCode elements" , messagesDoc , declaredAbbrevsSet , describedAbbrevsSet ) ; }
check given messages file for validity .
