Config parser

The config parser is responsible for parsing the IOC definition XML file, and then set the constructor of the component into the factory. The infrastructure of config parser is shown in the following diagram.

the infrastructure of config parser

The flow of parsing definition XML is as follows:

  1. Get the component definition XML string by Ajax.
  2. Initialize the string XML to XMLDocument by Util tools.
  3. Generate the constructor when parsing the XML according to value of each attribute.
  4. Register constructors into the factory.
The constructor of BTTConfigParser is as follows:
var BTTConfigParser = function(/*BTTFactory*/ factory){
	this.factory = factory;
}

When you create an instance of BTTConfigParser, you need to pass a BTTFactory instance as its parameter where the constructors of components are stored.

If you want to extend or revise the process of definition XML parsing, you can define a new parser which inherits BTTRespoitory class and can override the parse method.