Java Reference
In-Depth Information
The first step in transforming our business model to this Java model is to cre-
ate a dynamic instance model from our dnc.ecore model for use in testing the
QVT. The problem we immediately face is that because we have extended our
oocore.ecore
model but have not provided an extension of the
Package
class,
we have no capability to create a container for our test archetypes. The refer-
enced
oocore.ecore
model opens in the resource set, so we can right-click the
Package
class and create a new dynamic instance model; however, when we do
this, we can't create archetypes. The problem is that we have no references to the
dnc.ecore
model in the produced
model.xmi
file, shown here:
<?xml version="1.0" encoding="ASCII"?>
<oocore:Package xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:oocore="http://www.eclipse.org/2008/oocore"
xsi:schemaLocation="http://www.eclipse.org/2008/oocore
../../org.eclipse.dsl.oocore/model/oocore.ecore">
</oocore:Package>
To work around this problem, we simply need to add
xmlns
and
schemaLocation
for our
dnc.ecore
model in this file:
<?xml version="1.0" encoding="ASCII"?>
<oocore:Package xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:dnc=”http://www.eclipse.org/2008/dnc”
xmlns:oocore="http://www.eclipse.org/2008/oocore"
xsi:schemaLocation="
http://www.eclipse.org/2008/dnc dnc.ecore
http://www.eclipse.org/2008/oocore
../../org.eclipse.dsl.oocore/model/oocore.ecore">
</oocore:Package>
Now we can open the model in our reflective editor and add archetypes,
attributes, operations, associations, and references for use in testing. Figure 6-20
shows what the content of our test
model.xmi
looks like, although it doesn't indi-
cate that these archetypes were created in the package
org.eclipse.example
.
With a dynamic instance model to use as input, we can move on to creating
a transformation script to execute and see what the output looks like. The JEM
model comes with no editor of its own, so we can use either the text editor or
our friend the Sample Reflective Ecore Editor to view the output. Using the
Operational QVT Transformation
wizard, create a
dnc2jee.qvto
file in the
org.eclipse.dsl.dnc/transformations
directory. Alter the default trans-
formation definition to match the following:
Search WWH ::
Custom Search