Buggy code:
public class XMLParser { static final String DATA_CLASS = Alignment . class . getName ( ) ; static final String SEQUENCE_CLASS = Sequence . class . getName ( ) ; static final String STATE_CLASS = State . class . getName ( ) ; static final String LIKELIHOOD_CLASS = Distribution . class . getName ( ) ; static final String LOG_CLASS = Logger . class . getName ( ) ; static final String OPERATOR_CLASS = Operator . class . getName ( ) ; static final String REAL_PARAMETER_CLASS = RealParameter . class . getName ( ) ; static final String PLUGIN_CLASS = BEASTInterface . class . getName ( ) ; static final String INPUT_CLASS = Input . class . getName ( ) ; static final String TREE_CLASS = Tree . class . getName ( ) ; static final String RUNNABLE_CLASS = Runnable . class . getName ( ) ; public static final String BEAST_ELEMENT = "beast" ; public static final String MAP_ELEMENT = "map" ; public static final String DISTRIBUTION_ELEMENT = "distribution" ; public static final String OPERATOR_ELEMENT = "operator" ; public static final String INPUT_ELEMENT = "input" ; public static final String LOG_ELEMENT = "logger" ; public static final String DATA_ELEMENT = "data" ; public static final String SEQUENCE_ELEMENT = "sequence" ; public static final String STATE_ELEMENT = "state" ; public static final String TREE_ELEMENT = "tree" ; public static final String REAL_PARAMETER_ELEMENT = "parameter" ; public static final String RUN_ELEMENT = "run" ; public static final String PLATE_ELEMENT = "plate" ; Runnable m_runnable ; State m_state ; Document doc ; String m_sDataMap ; HashMap < String , BEASTInterface > IDMap ; HashMap < String , Integer [ ] > likelihoodMap ; HashMap < String , Node > IDNodeMap ; static HashMap < String , String > element2ClassMap ; static Set < String > reservedElements ; List < BEASTInterface > pluginsWaitingToInit ; List < Node > nodesWaitingToInit ; public HashMap < String , String > getElement2ClassMap ( ) { } String [ ] m_sNameSpaces ; boolean m_bInitialize = true ; XMLParser . RequiredInputProvider requiredInputProvider = null ; PartitionContext partitionContext = null ; public XMLParser ( ) { } public Runnable parseFile ( final File file ) throws Exception { } public List < BEASTInterface > parseTemplate ( final String sXML , final HashMap < String , BEASTInterface > sIDMap , final boolean bInitialize ) throws Exception { m_bInitialize = bInitialize ; final DocumentBuilderFactory factory = DocumentBuilderFactory . newInstance ( ) ; doc = factory . newDocumentBuilder ( ) . parse ( new InputSource ( new StringReader ( sXML ) ) ) ; doc . normalize ( ) ; XMLParserUtils . processPlates ( doc , XMLParser . PLATE_ELEMENT ) ; <START_BUG> XMLParserUtils . saveDocAsXML ( doc ) ; <END_BUG> IDMap = sIDMap ; likelihoodMap = new HashMap < String , Integer [ ] > ( ) ; IDNodeMap = new HashMap < String , Node > ( ) ; final List < BEASTInterface > plugins = new ArrayList < BEASTInterface > ( ) ; final NodeList nodes = doc . getElementsByTagName ( "*" ) ; if ( ( nodes == null ) || ( ( nodes . getLength ( ) ) == 0 ) ) { throw new Exception ( "Expected<seq2seq4repair_space>top<seq2seq4repair_space>level<seq2seq4repair_space>beast<seq2seq4repair_space>element<seq2seq4repair_space>in<seq2seq4repair_space>XML" ) ; } final Node topNode = nodes . item ( 0 ) ; final double fVersion = XMLParser . getAttributeAsDouble ( topNode , "version" ) ; if ( ( ( ! ( topNode . getNodeName ( ) . equals ( XMLParser . BEAST_ELEMENT ) ) ) || ( fVersion < 2.0 ) ) || ( fVersion == ( Double . MAX_VALUE ) ) ) { return plugins ; } initIDNodeMap ( topNode ) ; parseNameSpaceAndMap ( topNode ) ; final NodeList children = topNode . getChildNodes ( ) ; for ( int i = 0 ; i < ( children . getLength ( ) ) ; i ++ ) { if ( ( children . item ( i ) . getNodeType ( ) ) == ( Node . ELEMENT_NODE ) ) { final Node child = children . item ( i ) ; System . err . println ( child . getNodeName ( ) ) ; if ( ! ( child . getNodeName ( ) . equals ( XMLParser . MAP_ELEMENT ) ) ) { plugins . add ( createObject ( child , XMLParser . PLUGIN_CLASS , null ) ) ; } } } initPlugins ( ) ; return plugins ; } private void initPlugins ( ) throws Exception { } public BEASTInterface parseFragment ( final String sXML , final boolean bInitialize ) throws Exception { } public BEASTInterface parseBareFragment ( String sXML , final boolean bInitialize ) throws Exception { } public List < BEASTInterface > parseBareFragments ( final String sXML , final boolean bInitialize ) throws Exception { } public void parse ( ) throws Exception { } void initIDNodeMap ( final Node node ) throws Exception { } void parseNameSpaceAndMap ( final Node topNode ) throws XMLParserException { } public void setNameSpace ( final String sNameSpaceStr ) { } void parseRunElement ( final Node topNode ) throws Exception { } boolean checkType ( final String sClass , final BEASTInterface plugin ) throws Exception { } BEASTInterface createObject ( final Node node , final String sClass , final BEASTInterface parent ) throws Exception { } String guessClass ( final String sClass ) { } public static int getLevenshteinDistance ( final String s , final String t ) { } void parseInputs ( final BEASTInterface parent , final Node node ) throws Exception { } void setInput ( final Node node , final BEASTInterface plugin , final String sName , final BEASTInterface plugin2 ) throws XMLParserException { } void setInput ( final Node node , final BEASTInterface plugin , final String sName , final String sValue ) throws XMLParserException { } void register ( final Node node , final BEASTInterface plugin ) { } public static String getID ( final Node node ) { }

Fix:
XMLParserUtils . saveDocAsXML ( doc , "//tmp//beast2.xml" ) ;