Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » XML-Schema-to-whatever-mapping
XML-Schema-to-whatever-mapping [message #417478] Wed, 12 March 2008 20:59 Go to next message
Volker Wegert is currently offline Volker WegertFriend
Messages: 182
Registered: July 2009
Senior Member
Hi all,

I'm wondering whether I could use EMF (and oAW) to faciliate a task ahead. The
problem is, roughly speaking: I've got to create a bit of "glue logic" that
performs some technical and structural mapping tasks between two systems. The
"outward" side of the logic will have to deal with web services and rather
complex XML schemas - to simplify things a bit, let's take an example like

<a id="1" b="c" d="e">
<q id="10" r="s" t="u"/>
<q id="20" r="v" t="w">
<x y="z"/>
</q>
</a>

The "inward" part will have to deal with somewhat older structures that cannot
be nested in a tree-like fashion. This means that I have to "flatten" the data
on the way in (and vice versa on the way out):

a id b d
------------
1 c e

q id id_a r t
------------------
10 1 s u
20 1 v w

x id_a id_q y
---------------------
1 20 z

Since I have quite a number of these conversions to perform, I'd like to
define some kind of mapping and have the actual code generated from this
mapping, instead of hand-coding hundreds of stupid data converter classes.

I don't want to import the actual XML Schema into an Ecore model (because I
don't want to handle the data stream itself using EMF generated classes), I
rather want to have some kind of meta-meta-model that contains the XML Schema,
my "internal flat table schema" and the mapping settings in between.

Now I can think of a way to represent my tabular structures in an Ecore model
- but I don't really know whether what I want to do on the XML Schema side is
possible... Has anyone ever attempted to do something like this?

Volker

--
* Volker Wegert * http://www.volker-wegert.de/contact *
Teamwork is essential: You can always blame somebody else.
Re: XML-Schema-to-whatever-mapping [message #417480 is a reply to message #417478] Wed, 12 March 2008 21:40 Go to previous messageGo to next message
Enrico Schnepel is currently offline Enrico SchnepelFriend
Messages: 121
Registered: July 2009
Senior Member
Hello Volker,

I think it would be possible to have two or three metamodels
- "tree-MM":
a metamodel representing the tree structure
- "mapping-MM"
a metamodel referencing the first one to map tree-element-types to
column definitions.
- "column-MM"
this metamodel is either implicit and defined in the column
definitions of the mapping-MM or explicit and the mapping-MM would
reference elements of the tree-MM as well as this column-MM

using a model from the mapping-MM one could generate some xtend/xpand
transformations which do the job of flattening the tree into text/ and
parsing the text into the tree structure.

regards (from and to Berlin ;-) )

Enrico

Volker Wegert wrote:

> Hi all,
>
> I'm wondering whether I could use EMF (and oAW) to faciliate a task ahead.
> The problem is, roughly speaking: I've got to create a bit of "glue logic"
> that performs some technical and structural mapping tasks between two
> systems. The "outward" side of the logic will have to deal with web
> services and rather complex XML schemas - to simplify things a bit, let's
> take an example like
>
> <a id="1" b="c" d="e">
> <q id="10" r="s" t="u"/>
> <q id="20" r="v" t="w">
> <x y="z"/>
> </q>
> </a>
>
> The "inward" part will have to deal with somewhat older structures that
> cannot be nested in a tree-like fashion. This means that I have to
> "flatten" the data on the way in (and vice versa on the way out):
>
> a id b d
> ------------
> 1 c e
>
> q id id_a r t
> ------------------
> 10 1 s u
> 20 1 v w
>
> x id_a id_q y
> ---------------------
> 1 20 z
>
> Since I have quite a number of these conversions to perform, I'd like to
> define some kind of mapping and have the actual code generated from this
> mapping, instead of hand-coding hundreds of stupid data converter classes.
>
> I don't want to import the actual XML Schema into an Ecore model (because
> I don't want to handle the data stream itself using EMF generated
> classes), I rather want to have some kind of meta-meta-model that contains
> the XML Schema, my "internal flat table schema" and the mapping settings
> in between.
>
> Now I can think of a way to represent my tabular structures in an Ecore
> model - but I don't really know whether what I want to do on the XML
> Schema side is possible... Has anyone ever attempted to do something like
> this?
>
> Volker
>
Re: XML-Schema-to-whatever-mapping [message #417487 is a reply to message #417480] Thu, 13 March 2008 06:18 Go to previous messageGo to next message
Volker Wegert is currently offline Volker WegertFriend
Messages: 182
Registered: July 2009
Senior Member
Hi.

Enrico Schnepel <enrico.schnepel@randomice.net> writes:
> Volker Wegert wrote:
>> I'm wondering whether I could use EMF (and oAW) to faciliate a task ahead.
>> The problem is, roughly speaking: I've got to create a bit of "glue logic"
>> that performs some technical and structural mapping tasks between two
>> systems. The "outward" side of the logic will have to deal with web
>> services and rather complex XML schemas [..]
>>
>> The "inward" part will have to deal with somewhat older structures that
>> cannot be nested in a tree-like fashion. This means that I have to
>> "flatten" the data on the way in (and vice versa on the way out) [...]
>>
>> Since I have quite a number of these conversions to perform, I'd like to
>> define some kind of mapping and have the actual code generated from this
>> mapping, instead of hand-coding hundreds of stupid data converter classes.
>>
>> I don't want to import the actual XML Schema into an Ecore model (because
>> I don't want to handle the data stream itself using EMF generated
>> classes), I rather want to have some kind of meta-meta-model that contains
>> the XML Schema, my "internal flat table schema" and the mapping settings
>> in between.
>>
>> Now I can think of a way to represent my tabular structures in an Ecore
>> model - but I don't really know whether what I want to do on the XML
>> Schema side is possible... Has anyone ever attempted to do something like
>> this?
>
> I think it would be possible to have two or three metamodels
> - "tree-MM":
> a metamodel representing the tree structure
> - "mapping-MM"
> a metamodel referencing the first one to map tree-element-types to
> column definitions.
> - "column-MM"
> this metamodel is either implicit and defined in the column
> definitions of the mapping-MM or explicit and the mapping-MM would
> reference elements of the tree-MM as well as this column-MM
>
> using a model from the mapping-MM one could generate some xtend/xpand
> transformations which do the job of flattening the tree into text/ and
> parsing the text into the tree structure.

That is more or less exactly what I wanted to say in the first place. In a
way, I've already got the contents of the tree metamodel - my XML schema. One
could say I'm looking for an Ecore model that I can use to read XML Schemas,
just like I could use the UML2 metamodels to read some XMI class diagram...

Volker

--
* Volker Wegert * http://www.volker-wegert.de/contact *
"Wow. 256 is a lot of bits. I wonder where they put them all." (Bruce
Schneier)
Re: XML-Schema-to-whatever-mapping [message #417488 is a reply to message #417487] Thu, 13 March 2008 08:28 Go to previous messageGo to next message
Enrico Schnepel is currently offline Enrico SchnepelFriend
Messages: 121
Registered: July 2009
Senior Member
Hello volker,

I've just tried a xsd to ecore mapping, which worked for me out of the box.
I had to install some emf-xsd converter/mapping plugins. The ecore model
has been generated while creating the genmodel from the xsd file. This
might be what you are locking at?

Regards

Enrico

Volker Wegert wrote:

> Hi.
>
> Enrico Schnepel <enrico.schnepel@randomice.net> writes:
>> Volker Wegert wrote:
>>> I'm wondering whether I could use EMF (and oAW) to faciliate a task
>>> ahead. The problem is, roughly speaking: I've got to create a bit of
>>> "glue logic" that performs some technical and structural mapping tasks
>>> between two systems. The "outward" side of the logic will have to deal
>>> with web services and rather complex XML schemas [..]
>>>
>>> The "inward" part will have to deal with somewhat older structures that
>>> cannot be nested in a tree-like fashion. This means that I have to
>>> "flatten" the data on the way in (and vice versa on the way out) [...]
>>>
>>> Since I have quite a number of these conversions to perform, I'd like to
>>> define some kind of mapping and have the actual code generated from this
>>> mapping, instead of hand-coding hundreds of stupid data converter
>>> classes.
>>>
>>> I don't want to import the actual XML Schema into an Ecore model
>>> (because I don't want to handle the data stream itself using EMF
>>> generated classes), I rather want to have some kind of meta-meta-model
>>> that contains the XML Schema, my "internal flat table schema" and the
>>> mapping settings in between.
>>>
>>> Now I can think of a way to represent my tabular structures in an Ecore
>>> model - but I don't really know whether what I want to do on the XML
>>> Schema side is possible... Has anyone ever attempted to do something
>>> like this?
>>
>> I think it would be possible to have two or three metamodels
>> - "tree-MM":
>> a metamodel representing the tree structure
>> - "mapping-MM"
>> a metamodel referencing the first one to map tree-element-types to
>> column definitions.
>> - "column-MM"
>> this metamodel is either implicit and defined in the column
>> definitions of the mapping-MM or explicit and the mapping-MM would
>> reference elements of the tree-MM as well as this column-MM
>>
>> using a model from the mapping-MM one could generate some xtend/xpand
>> transformations which do the job of flattening the tree into text/ and
>> parsing the text into the tree structure.
>
> That is more or less exactly what I wanted to say in the first place. In a
> way, I've already got the contents of the tree metamodel - my XML schema.
> One could say I'm looking for an Ecore model that I can use to read XML
> Schemas, just like I could use the UML2 metamodels to read some XMI class
> diagram...
>
> Volker
>
Re: XML-Schema-to-whatever-mapping [message #417491 is a reply to message #417488] Thu, 13 March 2008 09:34 Go to previous messageGo to next message
Volker Wegert is currently offline Volker WegertFriend
Messages: 182
Registered: July 2009
Senior Member
Hi.

Enrico Schnepel wrote:

> I've just tried a xsd to ecore mapping, which worked for me out of the box.
> I had to install some emf-xsd converter/mapping plugins. The ecore model
> has been generated while creating the genmodel from the xsd file. This
> might be what you are locking at?

Just to quote myself: "I don't want to import the actual XML Schema into
an Ecore model (because I don't want to handle the data stream itself
using EMF generated classes)". I want to *load* the XML Schema *itself*
into some EMF generated structures, not use the XML schema to generate
something that can load data described by the schema.

Volker
Re: XML-Schema-to-whatever-mapping [message #417492 is a reply to message #417491] Thu, 13 March 2008 10:04 Go to previous messageGo to next message
Enrico Schnepel is currently offline Enrico SchnepelFriend
Messages: 121
Registered: July 2009
Senior Member
Hello,

I don't know if you tried the XMLReader/XMLWriter from
https://bugs.eclipse.org/bugs/show_bug.cgi?id=159700
it reads/writes the xml directly.

Enrico

Volker Wegert wrote:

> Hi.
>
> Enrico Schnepel wrote:
>
>> I've just tried a xsd to ecore mapping, which worked for me out of the
>> box. I had to install some emf-xsd converter/mapping plugins. The ecore
>> model has been generated while creating the genmodel from the xsd file.
>> This might be what you are locking at?
>
> Just to quote myself: "I don't want to import the actual XML Schema into
> an Ecore model (because I don't want to handle the data stream itself
> using EMF generated classes)". I want to *load* the XML Schema *itself*
> into some EMF generated structures, not use the XML schema to generate
> something that can load data described by the schema.
>
> Volker
Re: XML-Schema-to-whatever-mapping [message #417500 is a reply to message #417492] Thu, 13 March 2008 12:34 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33141
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------030500000304060500070008
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Volker,

Note that you can use dynamic EMF to process the original data stream
and hence don't really need to generate a model for your original
input. EMF can even be used to read XML for which there is no model and
effectively reduces down to an API equivalent DOM:

Binding XML to Java
< http://www.theserverside.com/tt/articles/article.tss?l=Bindi ngXMLJava>

With that type of approach, you're basically trying to do a model to
model transformation. All the oAW stuff applies equally well for a
generated model or a dynamic model, and things like ATL or QVT can be
used for model to model transformation.


Enrico Schnepel wrote:
> Hello,
>
> I don't know if you tried the XMLReader/XMLWriter from
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=159700
> it reads/writes the xml directly.
>
> Enrico
>
> Volker Wegert wrote:
>
>
>> Hi.
>>
>> Enrico Schnepel wrote:
>>
>>
>>> I've just tried a xsd to ecore mapping, which worked for me out of the
>>> box. I had to install some emf-xsd converter/mapping plugins. The ecore
>>> model has been generated while creating the genmodel from the xsd file.
>>> This might be what you are locking at?
>>>
>> Just to quote myself: "I don't want to import the actual XML Schema into
>> an Ecore model (because I don't want to handle the data stream itself
>> using EMF generated classes)". I want to *load* the XML Schema *itself*
>> into some EMF generated structures, not use the XML schema to generate
>> something that can load data described by the schema.
>>
>> Volker
>>
>
>


--------------030500000304060500070008
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Volker,<br>
<br>
Note that you can use dynamic EMF to process the original data stream
and hence don't really need to generate a model for your original
input.&nbsp; EMF can even be used to read XML for which there is no model
and effectively reduces down to an API equivalent DOM:<br>
<blockquote><a target="_out"
href=" http://www.theserverside.com/tt/articles/article.tss?l=Bindi ngXMLJava">Binding
XML to Java</a><br>
</blockquote>
With that type of approach, you're basically trying to do a model to
model transformation.&nbsp; All the oAW stuff applies equally well for a
generated model or a dynamic model, and things like ATL or QVT can be
used for model to model transformation.<br>
<br>
<br>
Enrico Schnepel wrote:
<blockquote cite="mid:frau7s$ohd$1@build.eclipse.org" type="cite">
<pre wrap="">Hello,

I don't know if you tried the XMLReader/XMLWriter from
<a class="moz-txt-link-freetext" href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=159700">https://bugs.eclipse.org/bugs/show_bug.cgi?id=159700</a>
it reads/writes the xml directly.

Enrico

Volker Wegert wrote:

</pre>
<blockquote type="cite">
<pre wrap="">Hi.

Enrico Schnepel wrote:

</pre>
<blockquote type="cite">
<pre wrap="">I've just tried a xsd to ecore mapping, which worked for me out of the
box. I had to install some emf-xsd converter/mapping plugins. The ecore
model has been generated while creating the genmodel from the xsd file.
This might be what you are locking at?
</pre>
</blockquote>
<pre wrap="">Just to quote myself: "I don't want to import the actual XML Schema into
an Ecore model (because I don't want to handle the data stream itself
using EMF generated classes)". I want to *load* the XML Schema *itself*
into some EMF generated structures, not use the XML schema to generate
something that can load data described by the schema.

Volker
</pre>
</blockquote>
<pre wrap=""><!---->
</pre>
</blockquote>
<br>
</body>
</html>

--------------030500000304060500070008--


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: XML-Schema-to-whatever-mapping [message #417511 is a reply to message #417500] Thu, 13 March 2008 22:32 Go to previous messageGo to next message
Volker Wegert is currently offline Volker WegertFriend
Messages: 182
Registered: July 2009
Senior Member
Hi,

this meta-thinking is really something that doesn't go too well with anything
else, especially not if beer plays any role in "anything else" on my side. :-)

Ed Merks <merks@ca.ibm.com> writes:
> Note that you can use dynamic EMF to process the original data stream and
> hence don't really need to generate a model for your original input.

I didn't want to in the first place. The generated code will most likely have
to run without EMF (yes, there's another world out there, a very sad one), and
so I can't rely on dynamic EMF either.

> With that type of approach, you're basically trying to do a model to model
> transformation.

Basically correct - and all I want is some kind of description of this
transformation (a model-to-model-transformation-model) that will help me
generate the code that actual performs it. A kind of
Meta-(model-to-model-transformation)-model.

I don't know about ATL or QVT, but in my oAW projects where I perform M2M
transformations, I've got an Ecore source meta-model (usually describing a
domain-specific model) and an Ecore target meta-model (usually describing some
technical model). I load whatever description came in from the domain side,
perform the transformation and go on with the technical model contents. The
transformation itself is implemented using the oAW tools.

What I want now is pretty much the same, but at a "meta-level" above
this. I've got source data that's described by an "XSD meta-model", and I've
got target data that I could easily create an Ecore meta-model for. For
various reasons (execution speed not being the smallest concern in this
project), I don't want to use too many dynamic technologies like oAW at
runtime: I want some POJOs that hold the data and some plain Java code that
performs the translation. (One could argue about the POJOs, but I definitely
don't want to parse some model transformation language for each transformation
when I've got thousands of messages per hour to process.)

Now if I had Ecore models on both sides, all this wouldn't be a problem: I'd
create an Ecore model in between that describes the mapping and then use some
generative approach during development to create the Java code. The mapping
definition file would contain information like "map field A in IStruct B to
field X in OStruct Y", so I'd to import the definitions of IStructs and
OStructs from the existing Ecore models and then define assignments in my
Ecore-in-between that say "EClass Assignment with EReference source of type
IStruct (which is an EClass in the source model)". Fine so far - I'd even try
to create some GMF-generated editor and let some poor student draw the mapping
rules.

Unfortunately, in this case, I've already got the domain model (my XML Schema)
on one side of the equation, so I'm not talking about "B, instanceof EClass
IStruct, which has an EAttribute A", but about <xs:complexType name="B"> with
an <xs:attribute name="A"> and so on. This means my mapping would have to
contain something like "map attribute X of complex type A to field X in
OStruct Y", and that's what causes my (imaginary?) troubles one level up: how
do I specify an "EClass Assignment with EReference source of type
attribute-of-complex-type"? Unless I'm totally mistaken here, I'd need some
Ecore that defines an "EClass Attribute", an "EClass ComplexType" and so
on. Something like "having used the XSD2Ecore import on
http://www.w3.org/2001/XMLSchema.xsd"...

'kay, now I've got a _real_ headache...

> Enrico Schnepel wrote:
> I don't know if you tried the XMLReader/XMLWriter from
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=159700
> it reads/writes the xml directly.

"It allows to use XSDs as meta models without having do deal with EMF/Ecore.
This works within workflows and the xpand editor (meta model aware code
completion)"

If I read this correctly, it allows me to specify the transformation "map
attribute X of complex type A to field X in OStruct Y" in an xpand file. This
is interesting, but not what I want because I don't want the oAW interpreter
to perform the transformation itself. I want it to read the rules and generate
the code that performs the transformation.

Volker

--
* Volker Wegert * http://www.volker-wegert.de/contact *
"In the spirit of taking things too far, here is a fully functional
5-dimensional analog of Rubik's cube."
(http://www.gravitation3d.com/magiccube5d/)
Re: XML-Schema-to-whatever-mapping [message #417512 is a reply to message #417511] Fri, 14 March 2008 06:57 Go to previous messageGo to next message
Enrico Schnepel is currently offline Enrico SchnepelFriend
Messages: 121
Registered: July 2009
Senior Member
Hello Volker,

the things are much clearer now.

For the mapping model you could load the ecore model resource from the
registered packages. now you could create references the to EClass and
EAttribute/EReference types. A to be created generator generates a java
application which uses the emf to load and store the xsd and text
ressources and transforms the data according the modelled rules. the
transformation should do the same as an xtend script but is java.
you could even use an oaw workflow to load resources and store them and use
your own workflow component in the middle to perform your transformation.

I would first create an xtend transformation for the task in the middle to
clarify the contents of the mapping model and what the java task should do
one time it is generated.

Now you could replace the workflow stuff with your own class to gain a
better performance.

This procedure will result in the usage of using a dynamic or static emf
model instance for the xsd-part. I think it would be possible to generate
some configuration and pojo classes out of the xsd ecore model for a pure
dom parser or an pojo-xml serialization library if you want to overcome
this restriction.

regards

Enrico

Volker Wegert wrote:
> Hi,
>
> this meta-thinking is really something that doesn't go too well with
> anything else, especially not if beer plays any role in "anything else" on
> my side. :-)
>
> Ed Merks <merks@ca.ibm.com> writes:
>> Note that you can use dynamic EMF to process the original data stream and
>> hence don't really need to generate a model for your original input.
>
> I didn't want to in the first place. The generated code will most likely
> have to run without EMF (yes, there's another world out there, a very sad
> one), and so I can't rely on dynamic EMF either.
>
>> With that type of approach, you're basically trying to do a model to
>> model transformation.
>
> Basically correct - and all I want is some kind of description of this
> transformation (a model-to-model-transformation-model) that will help me
> generate the code that actual performs it. A kind of
> Meta-(model-to-model-transformation)-model.
>
> I don't know about ATL or QVT, but in my oAW projects where I perform M2M
> transformations, I've got an Ecore source meta-model (usually describing a
> domain-specific model) and an Ecore target meta-model (usually describing
> some technical model). I load whatever description came in from the domain
> side, perform the transformation and go on with the technical model
> contents. The transformation itself is implemented using the oAW tools.
>
> What I want now is pretty much the same, but at a "meta-level" above
> this. I've got source data that's described by an "XSD meta-model", and
> I've got target data that I could easily create an Ecore meta-model for.
> For various reasons (execution speed not being the smallest concern in
> this project), I don't want to use too many dynamic technologies like oAW
> at runtime: I want some POJOs that hold the data and some plain Java code
> that performs the translation. (One could argue about the POJOs, but I
> definitely don't want to parse some model transformation language for each
> transformation when I've got thousands of messages per hour to process.)
>
> Now if I had Ecore models on both sides, all this wouldn't be a problem:
> I'd create an Ecore model in between that describes the mapping and then
> use some generative approach during development to create the Java code.
> The mapping definition file would contain information like "map field A in
> IStruct B to field X in OStruct Y", so I'd to import the definitions of
> IStructs and OStructs from the existing Ecore models and then define
> assignments in my Ecore-in-between that say "EClass Assignment with
> EReference source of type IStruct (which is an EClass in the source
> model)". Fine so far - I'd even try to create some GMF-generated editor
> and let some poor student draw the mapping rules.
>
> Unfortunately, in this case, I've already got the domain model (my XML
> Schema) on one side of the equation, so I'm not talking about "B,
> instanceof EClass IStruct, which has an EAttribute A", but about
> <xs:complexType name="B"> with an <xs:attribute name="A"> and so on. This
> means my mapping would have to contain something like "map attribute X of
> complex type A to field X in OStruct Y", and that's what causes my
> (imaginary?) troubles one level up: how do I specify an "EClass Assignment
> with EReference source of type attribute-of-complex-type"? Unless I'm
> totally mistaken here, I'd need some Ecore that defines an "EClass
> Attribute", an "EClass ComplexType" and so on. Something like "having used
> the XSD2Ecore import on http://www.w3.org/2001/XMLSchema.xsd"...
>
> 'kay, now I've got a _real_ headache...
>
>> Enrico Schnepel wrote:
>> I don't know if you tried the XMLReader/XMLWriter from
>> https://bugs.eclipse.org/bugs/show_bug.cgi?id=159700
>> it reads/writes the xml directly.
>
> "It allows to use XSDs as meta models without having do deal with
> EMF/Ecore. This works within workflows and the xpand editor (meta model
> aware code completion)"
>
> If I read this correctly, it allows me to specify the transformation "map
> attribute X of complex type A to field X in OStruct Y" in an xpand file.
> This is interesting, but not what I want because I don't want the oAW
> interpreter to perform the transformation itself. I want it to read the
> rules and generate the code that performs the transformation.
>
> Volker
>
Re: XML-Schema-to-whatever-mapping [message #417515 is a reply to message #417511] Fri, 14 March 2008 13:45 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33141
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------060205000109020600010604
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Volker,

Comments below.


Volker Wegert wrote:
> Hi,
>
> this meta-thinking is really something that doesn't go too well with anything
> else, especially not if beer plays any role in "anything else" on my side. :-)
>
> Ed Merks <merks@ca.ibm.com> writes:
>
>> Note that you can use dynamic EMF to process the original data stream and
>> hence don't really need to generate a model for your original input.
>>
>
> I didn't want to in the first place. The generated code will most likely have
> to run without EMF (yes, there's another world out there, a very sad one), and
> so I can't rely on dynamic EMF either.
>
I can't imagine a world where it's not possible to use a library/jar to
drive the application. That would indeed be a sad one!
>
>> With that type of approach, you're basically trying to do a model to model
>> transformation.
>>
>
> Basically correct - and all I want is some kind of description of this
> transformation (a model-to-model-transformation-model) that will help me
> generate the code that actual performs it. A kind of
> Meta-(model-to-model-transformation)-model.
>
It sounds like you might just use XSLT though if you don't want to use a
model...
> I don't know about ATL or QVT, but in my oAW projects where I perform M2M
> transformations, I've got an Ecore source meta-model (usually describing a
> domain-specific model) and an Ecore target meta-model (usually describing some
> technical model). I load whatever description came in from the domain side,
> perform the transformation and go on with the technical model contents. The
> transformation itself is implemented using the oAW tools.
>
That makes sense.
> What I want now is pretty much the same, but at a "meta-level" above
> this. I've got source data that's described by an "XSD meta-model", and I've
> got target data that I could easily create an Ecore meta-model for. For
> various reasons (execution speed not being the smallest concern in this
> project), I don't want to use too many dynamic technologies like oAW at
> runtime: I want some POJOs that hold the data and some plain Java code that
> performs the translation. (One could argue about the POJOs, but I definitely
> don't want to parse some model transformation language for each transformation
> when I've got thousands of messages per hour to process.)
>
I'd suggest you measure, measure, measure. I know folks are often
surprised to find that DOM takes more space than EMF objects (and more
space implies a degree of slowness). Things like being able to
represent Java primitives as actual primitives rather than as Strings
makes a big difference. You might well find that generated EMF models
are hard to beat.
> Now if I had Ecore models on both sides, all this wouldn't be a problem: I'd
> create an Ecore model in between that describes the mapping and then use some
> generative approach during development to create the Java code. The mapping
> definition file would contain information like "map field A in IStruct B to
> field X in OStruct Y", so I'd to import the definitions of IStructs and
> OStructs from the existing Ecore models and then define assignments in my
> Ecore-in-between that say "EClass Assignment with EReference source of type
> IStruct (which is an EClass in the source model)". Fine so far - I'd even try
> to create some GMF-generated editor and let some poor student draw the mapping
> rules.
>
> Unfortunately, in this case, I've already got the domain model (my XML Schema)
> on one side of the equation, so I'm not talking about "B, instanceof EClass
> IStruct, which has an EAttribute A", but about <xs:complexType name="B"> with
> an <xs:attribute name="A"> and so on.
Hmm. EMF supports XSDEcoreBuilder which lets you convert an *.xsd
instance to a *.ecore instance.
> This means my mapping would have to
> contain something like "map attribute X of complex type A to field X in
> OStruct Y", and that's what causes my (imaginary?)
If you map the XSD to Ecore, and then do the mapping between that Ecore
and another Ecore, isn't that equivalent.
> troubles one level up: how
> do I specify an "EClass Assignment with EReference source of type
> attribute-of-complex-type"?
Map to Ecore first.
> Unless I'm totally mistaken here, I'd need some
> Ecore that defines an "EClass Attribute", an "EClass ComplexType" and so
> on. Something like "having used the XSD2Ecore import on
> http://www.w3.org/2001/XMLSchema.xsd"...
>
The XSD model provides an Ecore model for XSD. That's what
XSDEcoreBuilder uses to convert an XSD instance to an Ecore instance.
> 'kay, now I've got a _real_ headache...
>
Meta things always cause a bit of confusing. It still seems to me you
are wanting to define a mapping between meta instance to define a
mapping between instances of those metas. So converting your schema to
Ecore and defining an Ecore to Ecore mapping, which you then use to do
instance to instance transformation seems like what you need to do.
>
>> Enrico Schnepel wrote:
>> I don't know if you tried the XMLReader/XMLWriter from
>> https://bugs.eclipse.org/bugs/show_bug.cgi?id=159700
>> it reads/writes the xml directly.
>>
>
> "It allows to use XSDs as meta models without having do deal with EMF/Ecore.
> This works within workflows and the xpand editor (meta model aware code
> completion)"
>
> If I read this correctly, it allows me to specify the transformation "map
> attribute X of complex type A to field X in OStruct Y" in an xpand file. This
> is interesting, but not what I want because I don't want the oAW interpreter
> to perform the transformation itself. I want it to read the rules and generate
> the code that performs the transformation.
>
If you take your schema and follow this tutorial, doesn't that give you
1/2 of what you need?

Tutorial: Generating an EMF Model using XML Schema
< http://help.eclipse.org/help33/index.jsp?topic=/org.eclipse. emf.doc/tutorials/xlibmod/xlibmod.html>

Then you can write code to transform instances of this model into
instances of your target model. And keep in mind that EMF can be used
as jars anywhere, and that you might be surprised to find it performs
better than any alternative you try. (Keep in mind that when reading and
writing many instances, it's especially important to performance tuning
options.EMF Performance Tips
< http://www.eclipse.org/modeling/emf/docs/performance/EMFPerf ormanceTips.html>

> Volker
>
>


--------------060205000109020600010604
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Volker,<br>
<br>
Comments below.<br>
<br>
<br>
Volker Wegert wrote:
<blockquote cite="mid:m2y78mp85y.fsf@gideon.home.volker-wegert.de"
type="cite">
<pre wrap="">Hi,

this meta-thinking is really something that doesn't go too well with anything
else, especially not if beer plays any role in "anything else" on my side. :-)

Ed Merks <a class="moz-txt-link-rfc2396E" href="mailto:merks@ca.ibm.com">&lt;merks@ca.ibm.com&gt;</a> writes:
</pre>
<blockquote type="cite">
<pre wrap="">Note that you can use dynamic EMF to process the original data stream and
hence don't really need to generate a model for your original input.
</pre>
</blockquote>
<pre wrap=""><!---->
I didn't want to in the first place. The generated code will most likely have
to run without EMF (yes, there's another world out there, a very sad one), and
so I can't rely on dynamic EMF either.
</pre>
</blockquote>
I can't imagine a world where it's not possible to use a library/jar to
drive the application.&nbsp; That would indeed be a sad one!<br>
<blockquote cite="mid:m2y78mp85y.fsf@gideon.home.volker-wegert.de"
type="cite">
<pre wrap="">
</pre>
<blockquote type="cite">
<pre wrap="">With that type of approach, you're basically trying to do a model to model
transformation.
</pre>
</blockquote>
<pre wrap=""><!---->
Basically correct - and all I want is some kind of description of this
transformation (a model-to-model-transformation-model) that will help me
generate the code that actual performs it. A kind of
Meta-(model-to-model-transformation)-model.
</pre>
</blockquote>
It sounds like you might just use XSLT though if you don't want to use
a model...<br>
<blockquote cite="mid:m2y78mp85y.fsf@gideon.home.volker-wegert.de"
type="cite">
<pre wrap="">
I don't know about ATL or QVT, but in my oAW projects where I perform M2M
transformations, I've got an Ecore source meta-model (usually describing a
domain-specific model) and an Ecore target meta-model (usually describing some
technical model). I load whatever description came in from the domain side,
perform the transformation and go on with the technical model contents. The
transformation itself is implemented using the oAW tools.
</pre>
</blockquote>
That makes sense.<br>
<blockquote cite="mid:m2y78mp85y.fsf@gideon.home.volker-wegert.de"
type="cite">
<pre wrap="">
What I want now is pretty much the same, but at a "meta-level" above
this. I've got source data that's described by an "XSD meta-model", and I've
got target data that I could easily create an Ecore meta-model for. For
various reasons (execution speed not being the smallest concern in this
project), I don't want to use too many dynamic technologies like oAW at
runtime: I want some POJOs that hold the data and some plain Java code that
performs the translation. (One could argue about the POJOs, but I definitely
don't want to parse some model transformation language for each transformation
when I've got thousands of messages per hour to process.)
</pre>
</blockquote>
I'd suggest you measure, measure, measure.&nbsp; I know folks are often
surprised to find that DOM takes more space than EMF objects (and more
space implies a degree of slowness).&nbsp; Things like being able to
represent Java primitives as actual primitives rather than as Strings
makes a big difference.&nbsp; You might well find that generated EMF models
are hard to beat.<br>
<blockquote cite="mid:m2y78mp85y.fsf@gideon.home.volker-wegert.de"
type="cite">
<pre wrap="">
Now if I had Ecore models on both sides, all this wouldn't be a problem: I'd
create an Ecore model in between that describes the mapping and then use some
generative approach during development to create the Java code. The mapping
definition file would contain information like "map field A in IStruct B to
field X in OStruct Y", so I'd to import the definitions of IStructs and
OStructs from the existing Ecore models and then define assignments in my
Ecore-in-between that say "EClass Assignment with EReference source of type
IStruct (which is an EClass in the source model)". Fine so far - I'd even try
to create some GMF-generated editor and let some poor student draw the mapping
rules.

Unfortunately, in this case, I've already got the domain model (my XML Schema)
on one side of the equation, so I'm not talking about "B, instanceof EClass
IStruct, which has an EAttribute A", but about &lt;xs:complexType name="B"&gt; with
an &lt;xs:attribute name="A"&gt; and so on.</pre>
</blockquote>
Hmm.&nbsp; EMF supports XSDEcoreBuilder which lets you convert an *.xsd
instance to a *.ecore instance.&nbsp; <br>
<blockquote cite="mid:m2y78mp85y.fsf@gideon.home.volker-wegert.de"
type="cite">
<pre wrap=""> This means my mapping would have to
contain something like "map attribute X of complex type A to field X in
OStruct Y", and that's what causes my (imaginary?)</pre>
</blockquote>
If you map the XSD to Ecore, and then do the mapping between that Ecore
and another Ecore, isn't that equivalent.<br>
<blockquote cite="mid:m2y78mp85y.fsf@gideon.home.volker-wegert.de"
type="cite">
<pre wrap=""> troubles one level up: how
do I specify an "EClass Assignment with EReference source of type
attribute-of-complex-type"? </pre>
</blockquote>
Map to Ecore first.<br>
<blockquote cite="mid:m2y78mp85y.fsf@gideon.home.volker-wegert.de"
type="cite">
<pre wrap="">Unless I'm totally mistaken here, I'd need some
Ecore that defines an "EClass Attribute", an "EClass ComplexType" and so
on. Something like "having used the XSD2Ecore import on
<a class="moz-txt-link-freetext" href="http://www.w3.org/2001/XMLSchema.xsd">http://www.w3.org/2001/XMLSchema.xsd</a>"...
</pre>
</blockquote>
The XSD model provides an Ecore model for XSD.&nbsp; That's what
XSDEcoreBuilder uses to convert an XSD instance to an Ecore instance.<br>
<blockquote cite="mid:m2y78mp85y.fsf@gideon.home.volker-wegert.de"
type="cite">
<pre wrap="">
'kay, now I've got a _real_ headache...
</pre>
</blockquote>
Meta things always cause a bit of confusing.&nbsp; It still seems to me you
are wanting to define a mapping between meta instance to define a
mapping between instances of those metas.&nbsp; So converting your schema to
Ecore and defining an Ecore to Ecore mapping, which you then use to do
instance to instance transformation seems like what you need to do.&nbsp; <br>
<blockquote cite="mid:m2y78mp85y.fsf@gideon.home.volker-wegert.de"
type="cite">
<pre wrap="">
</pre>
<blockquote type="cite">
<pre wrap="">Enrico Schnepel wrote:
I don't know if you tried the XMLReader/XMLWriter from
<a class="moz-txt-link-freetext" href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=159700">https://bugs.eclipse.org/bugs/show_bug.cgi?id=159700</a>
it reads/writes the xml directly.
</pre>
</blockquote>
<pre wrap=""><!---->
"It allows to use XSDs as meta models without having do deal with EMF/Ecore.
This works within workflows and the xpand editor (meta model aware code
completion)"

If I read this correctly, it allows me to specify the transformation "map
attribute X of complex type A to field X in OStruct Y" in an xpand file. This
is interesting, but not what I want because I don't want the oAW interpreter
to perform the transformation itself. I want it to read the rules and generate
the code that performs the transformation.
</pre>
</blockquote>
If you take your schema and follow this tutorial, doesn't that give you
1/2 of what you need?<br>
<blockquote><a
href=" http://help.eclipse.org/help33/index.jsp?topic=/org.eclipse. emf.doc/tutorials/xlibmod/xlibmod.html">Tutorial:
Generating an EMF Model using XML Schema</a><br>
</blockquote>
Then you can write code to transform instances of this model into
instances of your target model.&nbsp; And keep in mind that EMF can be used
as jars anywhere, and that you might be surprised to find it performs
better than any alternative you try. (Keep in mind that when reading
and writing many instances, it's especially important to performance
tuning options.<a
href=" http://www.eclipse.org/modeling/emf/docs/performance/EMFPerf ormanceTips.html">EMF
Performance Tips</a>
<blockquote cite="mid:m2y78mp85y.fsf@gideon.home.volker-wegert.de"
type="cite">
<pre wrap="">
Volker

</pre>
</blockquote>
<br>
</body>
</html>

--------------060205000109020600010604--


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: XML-Schema-to-whatever-mapping [message #417591 is a reply to message #417515] Sun, 16 March 2008 12:09 Go to previous messageGo to next message
Volker Wegert is currently offline Volker WegertFriend
Messages: 182
Registered: July 2009
Senior Member
Hi.

Ed Merks <merks@ca.ibm.com> writes:
> Volker Wegert wrote:
>> Ed Merks <merks@ca.ibm.com> writes:
>> The generated code will most likely have to run without EMF (yes, there's
>> another world out there, a very sad one), and so I can't rely on dynamic
>> EMF either.
> I can't imagine a world where it's not possible to use a library/jar to
> drive the application. That would indeed be a sad one!

It's a world where exactly one person (that would be me) in the development
department knows EMF, and none of the others have the time to learn it in case
I'm on vacation and the app starts to behave erratically. That's not a
situation I'd like to provoke for 80+ customers.

It's also a world were we'll be using some Web Service framework, and that
will most likely be some EMF-agnostic toolkit (probably Axis, or the Sun
toolkit with the name I keep forgetting all the time) that comes with its own
rules and would require additional effort to integrate. If anyone could prove
me wrong on this one, please do!

And finally it's a world in which we might face the requirement of porting the
entire application to the SAP NWDI environment - in a hurry. I have no
personal experience in this area, but from what I've heard, adding any
non-standard (not provided in the SAP distribution, that is) external
libraries usually turns out to be a nightmare.

>> Basically correct - and all I want is some kind of description of this
>> transformation (a model-to-model-transformation-model) that will help me
>> generate the code that actual performs it. A kind of
>> Meta-(model-to-model-transformation)-model.
> It sounds like you might just use XSLT though if you don't want to use a
> model...

If I could get my hands on the XML, that might be an idea... Still, I want the
input data to be validated against the schema, and as far as I can see, the WS
frameworks already provide this in the process of parsing the input
data. Also, the inner system doesn't understand XML but needs some strucutres
to be filled and Java methods to be called.

> I'd suggest you measure, measure, measure.

I wish I had the time to do some extensive testing :-)

> I know folks are often surprised to find that DOM takes more space than EMF
> objects (and more space implies a degree of slowness). Things like being
> able to represent Java primitives as actual primitives rather than as
> Strings makes a big difference. You might well find that generated EMF
> models are hard to beat.

If I can get them instead of whatever the WS framework spits out, I might even
succeed in convincing other people to take a closer look at EMF. But if I have
to copy the data from an existing DOM (more likely some StAX implementation)
into EMF just to perform another copy operation, there's nothing gained.

> Hmm. EMF supports XSDEcoreBuilder which lets you convert an *.xsd
> instance to a *.ecore instance.

Right - almost forgot about that since I never really used it. I just tried to
import the Schema files I've got so far. Apart from some namespace issues,
this doesn't look too bad...

>> This means my mapping would have to contain something like "map attribute
>> X of complex type A to field X in OStruct Y", and that's what causes my
>> (imaginary?)
> If you map the XSD to Ecore, and then do the mapping between that Ecore and
> another Ecore, isn't that equivalent.

I think it'll be woth a try - even if I don't use the Ecore models to generate
any data classes, I could still use them for mapping purposes...

>> Unless I'm totally mistaken here, I'd need some
>> Ecore that defines an "EClass Attribute", an "EClass ComplexType" and so
>> on. Something like "having used the XSD2Ecore import on
>> http://www.w3.org/2001/XMLSchema.xsd"...
> The XSD model provides an Ecore model for XSD. That's what
> XSDEcoreBuilder uses to convert an XSD instance to an Ecore instance.

*ahem* This is _possible_?

..oO( One Ecore to rule them all, one Ecore to find them... )

>> 'kay, now I've got a _real_ headache...
> Meta things always cause a bit of confusing. It still seems to me you
> are wanting to define a mapping between meta instance to define a
> mapping between instances of those metas.

Exactly.

> So converting your schema to Ecore and defining an Ecore to Ecore mapping,
> which you then use to do instance to instance transformation seems like what
> you need to do.

Or - in case I can't use the EMF generated classes at runtime - use the
transformation file (.ecore2ecore) to drive my code generation at design
time.

> And keep in mind that EMF can be used as jars anywhere

I'm tempted to let someone who know NWDI better than I do have a look at this
assumption. ;-)

> and that you might be surprised to find it performs better than any
> alternative you try

If I end up having to build my own data objects, EMF is the way to go - I
don't ever want to hand-code dozens of stupid container classes again when I
can get _intelligent_ container classes from EMF. However, I still hope that I
can get away without that and just have some code generated that is not much
more complex than the one shown in the WTP tutorials:
http://tinyurl.com/2uhqoc or http://tinyurl.com/ynu8mr

Volker

--
* Volker Wegert * http://www.volker-wegert.de/contact *
141 Reasons why you can't find your system administrator: 111. Trying to
*avoid* being in a meeting
Re: XML-Schema-to-whatever-mapping [message #417592 is a reply to message #417512] Sun, 16 March 2008 12:22 Go to previous messageGo to next message
Volker Wegert is currently offline Volker WegertFriend
Messages: 182
Registered: July 2009
Senior Member
Enrico Schnepel <enrico.schnepel@randomice.net> writes:
> the things are much clearer now.

I'm not so sure....

> A to be created generator generates a java
> application which uses the emf to load and store the xsd and text
> ressources

There are no XSD or text resources. I've got some DOM, StAX or
whatever-the-web-service-framework-likes-on-tuesday-evenings classes on one
side and the SAP Java Connector on the other. No persistent storage of
anything, not in this part of the application.

> the
> transformation should do the same as an xtend script but is java.

That's correct.

> I would first create an xtend transformation for the task in the middle to
> clarify the contents of the mapping model and what the java task should do
> one time it is generated.

I know what I want to map and what the Java code should do - no need to write
it down once...

> Now you could replace the workflow stuff with your own class to gain a
> better performance.

....just to write it down again.

> This procedure will result in the usage of using a dynamic or static emf
> model instance for the xsd-part.

....which is more or less what I'd like to avoid.

Volker


--
* Volker Wegert * http://www.volker-wegert.de/contact *
It's not a bug, it's tradition!
Re: XML-Schema-to-whatever-mapping [message #417597 is a reply to message #417591] Mon, 17 March 2008 01:22 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33141
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------010703010007060800060707
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Volker,

Comments below.


Volker Wegert wrote:
> Hi.
>
> Ed Merks <merks@ca.ibm.com> writes:
>
>> Volker Wegert wrote:
>>
>>> Ed Merks <merks@ca.ibm.com> writes:
>>> The generated code will most likely have to run without EMF (yes, there's
>>> another world out there, a very sad one), and so I can't rely on dynamic
>>> EMF either.
>>>
>> I can't imagine a world where it's not possible to use a library/jar to
>> drive the application. That would indeed be a sad one!
>>
>
> It's a world where exactly one person (that would be me) in the development
> department knows EMF, and none of the others have the time to learn it in case
> I'm on vacation and the app starts to behave erratically. That's not a
> situation I'd like to provoke for 80+ customers.
>
No matter how you do it, they'd need to learn that. And of course when
people have problems, I'm always ready to help them out...
> It's also a world were we'll be using some Web Service framework, and that
> will most likely be some EMF-agnostic toolkit (probably Axis, or the Sun
> toolkit with the name I keep forgetting all the time) that comes with its own
> rules and would require additional effort to integrate. If anyone could prove
> me wrong on this one, please do!
>
Yet more rules. I wonder why these ones are okay? :-P
> And finally it's a world in which we might face the requirement of porting the
> entire application to the SAP NWDI environment - in a hurry. I have no
> personal experience in this area, but from what I've heard, adding any
> non-standard (not provided in the SAP distribution, that is) external
> libraries usually turns out to be a nightmare.
>
I suppose it will be a nightmare then no matter what you use? Of you
mean that any time you use a library other than the bar JDK it's a
nightmare?
>
>>> Basically correct - and all I want is some kind of description of this
>>> transformation (a model-to-model-transformation-model) that will help me
>>> generate the code that actual performs it. A kind of
>>> Meta-(model-to-model-transformation)-model.
>>>
>> It sounds like you might just use XSLT though if you don't want to use a
>> model...
>>
>
> If I could get my hands on the XML, that might be an idea... Still, I want the
> input data to be validated against the schema, and as far as I can see, the WS
> frameworks already provide this in the process of parsing the input
> data. Also, the inner system doesn't understand XML but needs some strucutres
> to be filled and Java methods to be called.
>
Sounds like you need generated APIs of some sort?
>
>> I'd suggest you measure, measure, measure.
>>
>
> I wish I had the time to do some extensive testing :-)
>
They want it done yesterday hey! I'd be tempted to tell them that their
bad planning isn't an emergency for my. Makes you wonder why I still
have a job hey? :-P
>
>> I know folks are often surprised to find that DOM takes more space than EMF
>> objects (and more space implies a degree of slowness). Things like being
>> able to represent Java primitives as actual primitives rather than as
>> Strings makes a big difference. You might well find that generated EMF
>> models are hard to beat.
>>
>
> If I can get them instead of whatever the WS framework spits out, I might even
> succeed in convincing other people to take a closer look at EMF. But if I have
> to copy the data from an existing DOM (more likely some StAX implementation)
> into EMF just to perform another copy operation, there's nothing gained.
>
EMF can easily construct an instance given a DOM. But indeed, if you
can do it with DOM and you already have a DOM, converting isn't going to
speed things up for sure.
>
>> Hmm. EMF supports XSDEcoreBuilder which lets you convert an *.xsd
>> instance to a *.ecore instance.
>>
>
> Right - almost forgot about that since I never really used it. I just tried to
> import the Schema files I've got so far. Apart from some namespace issues,
> this doesn't look too bad...
>
>
>>> This means my mapping would have to contain something like "map attribute
>>> X of complex type A to field X in OStruct Y", and that's what causes my
>>> (imaginary?)
>>>
>> If you map the XSD to Ecore, and then do the mapping between that Ecore and
>> another Ecore, isn't that equivalent.
>>
>
> I think it'll be woth a try - even if I don't use the Ecore models to generate
> any data classes, I could still use them for mapping purposes...
>
>
>>> Unless I'm totally mistaken here, I'd need some
>>> Ecore that defines an "EClass Attribute", an "EClass ComplexType" and so
>>> on. Something like "having used the XSD2Ecore import on
>>> http://www.w3.org/2001/XMLSchema.xsd"...
>>>
>> The XSD model provides an Ecore model for XSD. That's what
>> XSDEcoreBuilder uses to convert an XSD instance to an Ecore instance.
>>
>
> *ahem* This is _possible_?
>
> .oO( One Ecore to rule them all, one Ecore to find them... )
>
Actually, Ecore.ecore is the one metamodel that binds them all... :-P
>
>>> 'kay, now I've got a _real_ headache...
>>>
>> Meta things always cause a bit of confusing. It still seems to me you
>> are wanting to define a mapping between meta instance to define a
>> mapping between instances of those metas.
>>
>
> Exactly.
>
>
>> So converting your schema to Ecore and defining an Ecore to Ecore mapping,
>> which you then use to do instance to instance transformation seems like what
>> you need to do.
>>
>
> Or - in case I can't use the EMF generated classes at runtime - use the
> transformation file (.ecore2ecore) to drive my code generation at design
> time.
>
>
>> And keep in mind that EMF can be used as jars anywhere
>>
>
> I'm tempted to let someone who know NWDI better than I do have a look at this
> assumption. ;-)
>
I know a great many people do use EMF standalone as jars, so that
absolutely works.
>
>> and that you might be surprised to find it performs better than any
>> alternative you try
>>
>
> If I end up having to build my own data objects, EMF is the way to go - I
> don't ever want to hand-code dozens of stupid container classes again when I
> can get _intelligent_ container classes from EMF. However, I still hope that I
> can get away without that and just have some code generated that is not much
> more complex than the one shown in the WTP tutorials:
> http://tinyurl.com/2uhqoc or http://tinyurl.com/ynu8mr
>
The thing is, if you have such plain old things, then how do you build
instances of them from XML and serialize them to XML?
> Volker
>
>
Good luck with whatever works out best for your scenario. If there are
EMF things I can help with, I'll try my best.


--------------010703010007060800060707
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Volker,<br>
<br>
Comments below.<br>
<br>
<br>
Volker Wegert wrote:
<blockquote cite="mid:m2ejaag99q.fsf@gideon.home.volker-wegert.de"
type="cite">
<pre wrap="">Hi.

Ed Merks <a class="moz-txt-link-rfc2396E" href="mailto:merks@ca.ibm.com">&lt;merks@ca.ibm.com&gt;</a> writes:
</pre>
<blockquote type="cite">
<pre wrap="">Volker Wegert wrote:
</pre>
<blockquote type="cite">
<pre wrap="">Ed Merks <a class="moz-txt-link-rfc2396E" href="mailto:merks@ca.ibm.com">&lt;merks@ca.ibm.com&gt;</a> writes:
The generated code will most likely have to run without EMF (yes, there's
another world out there, a very sad one), and so I can't rely on dynamic
EMF either.
</pre>
</blockquote>
<pre wrap="">I can't imagine a world where it's not possible to use a library/jar to
drive the application. That would indeed be a sad one!
</pre>
</blockquote>
<pre wrap=""><!---->
It's a world where exactly one person (that would be me) in the development
department knows EMF, and none of the others have the time to learn it in case
I'm on vacation and the app starts to behave erratically. That's not a
situation I'd like to provoke for 80+ customers.
</pre>
</blockquote>
No matter how you do it, they'd need to learn that.&nbsp; And of course when
people have problems, I'm always ready to help them out...<br>
<blockquote cite="mid:m2ejaag99q.fsf@gideon.home.volker-wegert.de"
type="cite">
<pre wrap="">
It's also a world were we'll be using some Web Service framework, and that
will most likely be some EMF-agnostic toolkit (probably Axis, or the Sun
toolkit with the name I keep forgetting all the time) that comes with its own
rules and would require additional effort to integrate. If anyone could prove
me wrong on this one, please do!
</pre>
</blockquote>
Yet more rules.&nbsp; I wonder why these ones are okay?&nbsp; :-P<br>
<blockquote cite="mid:m2ejaag99q.fsf@gideon.home.volker-wegert.de"
type="cite">
<pre wrap="">
And finally it's a world in which we might face the requirement of porting the
entire application to the SAP NWDI environment - in a hurry. I have no
personal experience in this area, but from what I've heard, adding any
non-standard (not provided in the SAP distribution, that is) external
libraries usually turns out to be a nightmare.
</pre>
</blockquote>
I suppose it will be a nightmare then no matter what you use?&nbsp;&nbsp; Of you
mean that any time you use a library other than the bar JDK it's a
nightmare?<br>
<blockquote cite="mid:m2ejaag99q.fsf@gideon.home.volker-wegert.de"
type="cite">
<pre wrap="">
</pre>
<blockquote type="cite">
<blockquote type="cite">
<pre wrap="">Basically correct - and all I want is some kind of description of this
transformation (a model-to-model-transformation-model) that will help me
generate the code that actual performs it. A kind of
Meta-(model-to-model-transformation)-model.
</pre>
</blockquote>
<pre wrap="">It sounds like you might just use XSLT though if you don't want to use a
model...
</pre>
</blockquote>
<pre wrap=""><!---->
If I could get my hands on the XML, that might be an idea... Still, I want the
input data to be validated against the schema, and as far as I can see, the WS
frameworks already provide this in the process of parsing the input
data. Also, the inner system doesn't understand XML but needs some strucutres
to be filled and Java methods to be called.
</pre>
</blockquote>
Sounds like you need generated APIs of some sort?<br>
<blockquote cite="mid:m2ejaag99q.fsf@gideon.home.volker-wegert.de"
type="cite">
<pre wrap="">
</pre>
<blockquote type="cite">
<pre wrap="">I'd suggest you measure, measure, measure.
</pre>
</blockquote>
<pre wrap=""><!---->
I wish I had the time to do some extensive testing :-)
</pre>
</blockquote>
They want it done yesterday hey!&nbsp; I'd be tempted to tell them that
their bad planning isn't an emergency for my.&nbsp; Makes you wonder why I
still have a job hey? :-P<br>
<blockquote cite="mid:m2ejaag99q.fsf@gideon.home.volker-wegert.de"
type="cite">
<pre wrap="">
</pre>
<blockquote type="cite">
<pre wrap="">I know folks are often surprised to find that DOM takes more space than EMF
objects (and more space implies a degree of slowness). Things like being
able to represent Java primitives as actual primitives rather than as
Strings makes a big difference. You might well find that generated EMF
models are hard to beat.
</pre>
</blockquote>
<pre wrap=""><!---->
If I can get them instead of whatever the WS framework spits out, I might even
succeed in convincing other people to take a closer look at EMF. But if I have
to copy the data from an existing DOM (more likely some StAX implementation)
into EMF just to perform another copy operation, there's nothing gained.
</pre>
</blockquote>
EMF can easily construct an instance given a DOM.&nbsp; But indeed, if you
can do it with DOM and you already have a DOM, converting isn't going
to speed things up for sure.<br>
<blockquote cite="mid:m2ejaag99q.fsf@gideon.home.volker-wegert.de"
type="cite">
<pre wrap="">
</pre>
<blockquote type="cite">
<pre wrap="">Hmm. EMF supports XSDEcoreBuilder which lets you convert an *.xsd
instance to a *.ecore instance.
</pre>
</blockquote>
<pre wrap=""><!---->
Right - almost forgot about that since I never really used it. I just tried to
import the Schema files I've got so far. Apart from some namespace issues,
this doesn't look too bad...

</pre>
<blockquote type="cite">
<blockquote type="cite">
<pre wrap="">This means my mapping would have to contain something like "map attribute
X of complex type A to field X in OStruct Y", and that's what causes my
(imaginary?)
</pre>
</blockquote>
<pre wrap="">If you map the XSD to Ecore, and then do the mapping between that Ecore and
another Ecore, isn't that equivalent.
</pre>
</blockquote>
<pre wrap=""><!---->
I think it'll be woth a try - even if I don't use the Ecore models to generate
any data classes, I could still use them for mapping purposes...

</pre>
<blockquote type="cite">
<blockquote type="cite">
<pre wrap="">Unless I'm totally mistaken here, I'd need some
Ecore that defines an "EClass Attribute", an "EClass ComplexType" and so
on. Something like "having used the XSD2Ecore import on
<a class="moz-txt-link-freetext" href="http://www.w3.org/2001/XMLSchema.xsd">http://www.w3.org/2001/XMLSchema.xsd</a>"...
</pre>
</blockquote>
<pre wrap="">The XSD model provides an Ecore model for XSD. That's what
XSDEcoreBuilder uses to convert an XSD instance to an Ecore instance.
</pre>
</blockquote>
<pre wrap=""><!---->
*ahem* This is _possible_?

..oO( One Ecore to rule them all, one Ecore to find them... )
</pre>
</blockquote>
Actually, Ecore.ecore is the one metamodel that binds them all...&nbsp; :-P<br>
<blockquote cite="mid:m2ejaag99q.fsf@gideon.home.volker-wegert.de"
type="cite">
<pre wrap="">
</pre>
<blockquote type="cite">
<blockquote type="cite">
<pre wrap="">'kay, now I've got a _real_ headache...
</pre>
</blockquote>
<pre wrap="">Meta things always cause a bit of confusing. It still seems to me you
are wanting to define a mapping between meta instance to define a
mapping between instances of those metas.
</pre>
</blockquote>
<pre wrap=""><!---->
Exactly.

</pre>
<blockquote type="cite">
<pre wrap="">So converting your schema to Ecore and defining an Ecore to Ecore mapping,
which you then use to do instance to instance transformation seems like what
you need to do.
</pre>
</blockquote>
<pre wrap=""><!---->
Or - in case I can't use the EMF generated classes at runtime - use the
transformation file (.ecore2ecore) to drive my code generation at design
time.

</pre>
<blockquote type="cite">
<pre wrap="">And keep in mind that EMF can be used as jars anywhere
</pre>
</blockquote>
<pre wrap=""><!---->
I'm tempted to let someone who know NWDI better than I do have a look at this
assumption. ;-)
</pre>
</blockquote>
I know a great many people do use EMF standalone as jars, so that
absolutely works.<br>
<blockquote cite="mid:m2ejaag99q.fsf@gideon.home.volker-wegert.de"
type="cite">
<pre wrap="">
</pre>
<blockquote type="cite">
<pre wrap="">and that you might be surprised to find it performs better than any
alternative you try
</pre>
</blockquote>
<pre wrap=""><!---->
If I end up having to build my own data objects, EMF is the way to go - I
don't ever want to hand-code dozens of stupid container classes again when I
can get _intelligent_ container classes from EMF. However, I still hope that I
can get away without that and just have some code generated that is not much
more complex than the one shown in the WTP tutorials:
<a class="moz-txt-link-freetext" href="http://tinyurl.com/2uhqoc">http://tinyurl.com/2uhqoc</a> or <a class="moz-txt-link-freetext" href="http://tinyurl.com/ynu8mr">http://tinyurl.com/ynu8mr</a>
</pre>
</blockquote>
The thing is, if you have such plain old things, then how do you build
instances of them from XML and serialize them to XML?<br>
<blockquote cite="mid:m2ejaag99q.fsf@gideon.home.volker-wegert.de"
type="cite">
<pre wrap="">
Volker

</pre>
</blockquote>
Good luck with whatever works out best for your scenario.&nbsp; If there are
EMF things I can help with, I'll try my best.<br>
<br>
</body>
</html>

--------------010703010007060800060707--


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: XML-Schema-to-whatever-mapping [message #417614 is a reply to message #417597] Mon, 17 March 2008 21:01 Go to previous message
Volker Wegert is currently offline Volker WegertFriend
Messages: 182
Registered: July 2009
Senior Member
Hi.

Ed Merks <merks@ca.ibm.com> writes:
> Volker Wegert wrote:
>> Ed Merks <merks@ca.ibm.com> writes:
>>> Volker Wegert wrote:
>>>> Ed Merks <merks@ca.ibm.com> writes:
>>> I can't imagine a world where it's not possible to use a library/jar to
>>> drive the application. That would indeed be a sad one!
>> It's a world where exactly one person (that would be me) in the development
>> department knows EMF, and none of the others have the time to learn it in case
>> I'm on vacation and the app starts to behave erratically. That's not a
>> situation I'd like to provoke for 80+ customers.
> No matter how you do it, they'd need to learn that.

More precisely: They do know Java, JBoss, Axis/Sun WS. They don't know about
the wonders of EMF (yet). I'm working on that...

>> It's also a world were we'll be using some Web Service framework [...] that
>> comes with its own rules [...]
> Yet more rules. I wonder why these ones are okay? :-P

I wondered if there's any way to work without a WS framework, and from what
I've seen, there's no real alternative unless I want to write all of the stuff
myself.

>> [SAP NWDI]
> I suppose it will be a nightmare then no matter what you use?

I'd say that's a pretty good description of the situation, but then I'll
probably be beaten up by the colleagues tomorrow :-)

>> If I could get my hands on the XML, that might be an idea... Still, I want the
>> input data to be validated against the schema, and as far as I can see, the WS
>> frameworks already provide this in the process of parsing the input
>> data. Also, the inner system doesn't understand XML but needs some strucutres
>> to be filled and Java methods to be called.
> Sounds like you need generated APIs of some sort?

Yes. Generated APIs on the Web Service side (that's what the WS framework
provides), generic APIs on the legacy side (something like
foo.getParameter("BAR").setValue(baz)) and now please some generated code in
between :-)

>> However, I still hope that I can get away without that and just have some
>> code generated that is not much more complex than the one shown in the WTP
>> tutorials: http://tinyurl.com/2uhqoc or http://tinyurl.com/ynu8mr
> The thing is, if you have such plain old things, then how do you build
> instances of them from XML and serialize them to XML?

I don't - at least I don't code it. If you follow these tutorials (or have
some intern follow them :-p), you'll see a bunch of generated classes that do
this.

Volker

--
* Volker Wegert * http://www.volker-wegert.de/contact *
"Dream as if you'll live forever, live as if you'll die today." (James Dean)
Previous Topic:EMF Adapters
Next Topic:EPackage.getEClassifiers() EList order
Goto Forum:
  


Current Time: Fri Apr 26 03:20:58 GMT 2024

Powered by FUDForum. Page generated in 0.04647 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top