Work with external entities and model2xml. Fix bugs with constants