Looking do the network requests within Pentaho User Console, when we ask to create or modify a model, it calls the pentaho/gwtrpc/modelerService.
As the data-access/plugin.xml shows us:
<webservice
id="modelerService"
type="xml,gwt"
class="org.pentaho.platform.dataaccess.datasource.wizard.service.impl.ModelerService"/>
This service is implemented under the class ModelerService - here's the source code.
It's definitely possible to programmatically generate them xmi. Not directly using the xml mondrian schema, you'll only have to parse it - or to use your model pre-mondrian-xml - for then applying to the API and generating the CWM-based XML.
Focus on building up the org.pentaho.metadata.model.Domain and then serializing it to the xmi.
Here's the starting point of your toolbox: https://github.com/pentaho/data-access