protected String extractHeaderComment ( File xmlFile ) throws MojoExecutionException { try { SAXParser parser = SAXParserFactory . newInstance ( ) . newSAXParser ( ) ; SaxHeaderCommentHandler handler = new SaxHeaderCommentHandler ( ) ; parser . setProperty ( "http://xml.org/sax/properties/lexical-handler" , handler ) ; parser . parse ( xmlFile , handler ) ; return handler . getHeaderComment ( ) ; } catch ( Exception e ) { throw new MojoExecutionException ( "Failed to parse XML from " + xmlFile , e ) ; } }
This method extracts the XML header comment if available .