Hi Sven,
Nice to see that "the master" take time to answer dummy questions :-) Thanks a lot ! After having playing with Ruby during these last 3 years is my Java & EMF knowledge a little bit rosty ! Many thinks have changed.
In the old solution (xtext/xtend 0.7) we have simply transform with Xtend the DSL instance to an XSD instance :
<workflow>
<bean class="org.eclipse.emf.mwe.utils.StandaloneSetup" platformUri=".."/>
<component class="org.eclipse.xtext.MweReader" uri="${model_uri}">
<!-- this class will be generated by the xtext generator -->
<register class="de.uba.ics.FaktendatenStandaloneSetup"/>
</component>
<bean id="xsd_metamodel" class="org.eclipse.xtend.typesystem.xsd.XSDMetaModel">
<schemaFile value="metamodel/xml.xsd" />
<schemaFile value="metamodel/xsd.xsd" />
</bean>
<component class="org.eclipse.xtend.XtendComponent">
<metaModel idRef="xsd_metamodel" />
<invoke value="templates::dsl2xsd::dsl2xsd(model)" />
<outputSlot value="xsd_model" />
</component>
<component class="org.eclipse.xtend.typesystem.xsd.XMLWriter">
<metaModel idRef="xsd_metamodel" />
<modelSlot value="xsd_model" />
<uri value="${targetDir}/${fileName}.xsd" />
</component>
</workflow>
with the Xtend transformation dsl2xsd.ext looking like this:
import xsd;
import type; // for QName
import faktendaten;
extension org::eclipse::xtend::typesystem::xsd::lib::qname;
extension org::eclipse::xtend::typesystem::xsd::lib::map;
extension org::eclipse::xtend::util::stdlib::io;
extension templates::extensions;
String filename(XsdDocumentRoot r) :
r.schema.targetNamespace.split("/").last() + ".xsd"
;
String namespace(faktendaten::Model m) : defaultTargetNamespace() + m.name;
String namespace(faktendaten::Type t) : ((Model)t.eContainer).namespace();
create XsdDocumentRoot dsl2xsd(Model m) :
this.createNamespacePrefixes(m) -> (
let s = new SchemaType :
s.setTargetNamespace(m.namespace()) ->
s.complexType.addAll(m.types.typeSelect(Type).createXsdType()) ->
m.hierarchy != null ? s.complexType.add(createXsdType(m.hierarchy)) : null ->
s.^import.addAll(m.imports.createImport())->
m.doc.value != null ? (
s.annotation.add(createAnnotationWithDocumentation(m.doc.value))
) : (
null
) ->
this.setSchema(s)
)
;
create TopLevelComplexType createXsdType(Type t) :
...
;
...
The nice thing was that we do not had to write with Xpand the XSD generator. We simply transform the DSL-grammar (metamodel) to the XSD-metamodel and then let the org.eclipse.xtend.typesystem.xsd.XMLWriter do the job.
I assume that I have now to rewrite the M2M transformation within the MyDSLGenerator.xtend. and find the new XMLWriter. Right ?
Thanks for your help
Viele Grüsse aus Zürich
Antoine