|
|
|
Re: Element names to Java types [message #543478 is a reply to message #543315] |
Tue, 29 June 2010 14:31 |
Ed Merks Messages: 33142 Registered: July 2009 |
Senior Member |
|
|
Dirk,
Comments below.
Dirk Hoffmann wrote:
> Am 28.06.2010 19:14, schrieb Ed Merks:
>> Dirk,
>>
>> Comments below.
>>
>> Dirk Hoffmann wrote:
>>> Hi,
>>>
>>> when going from XSD to Ecore schema types are mapped to Java types.
>>>
>>> Unfortunately for my use case I'd rather map XSD element names to Java
>>> types.
>> I'm not sure that even makes sense. What would that mean? You certainly
>> don't need such a thing so why would you want such a thing?
> Yes that sounds silly but so is the use case. In the long term we want
> to not only provide a Java binding but also a binding for the Tcl
> script language. Those who will be using the Tcl binding don't care
> about the schema at all. The only thing they see are the XML instance
> files. The schema is made in a way so that for almost all XML elements
> there is only a single type. In most cases an element named X is of
> type XType.
You can use ecore:type annotations to control the name of the type. If
the type uniquely determines the element, you can suppress the document
root when serializing and deserializing.
> Unfortunately there are quite some exceptions to this schema causing
> the Tcl or Java programmer confusion. We are however able to extract
> the mapping from element names to type names with a simple shell
> script. The mapping could be used to change the way the XSD is
> converted to the Ecore or the code is generated from the genmodel.
>>>
>>> How would that be possible with EMF, e.g. by using dynamic templates?
>> You're asking about the mapping of XSD to Ecore but dynamic templates
>> are only about the mapping of Ecore to Java.
> Yes, sorry actually I'm aware of this. I was just before leaving off
> work. The ideal solution would be to already have the element names in
> the Ecore model. But if that is not feasible we could change the
> templates. Whenever the template would issue a type name this name
> would be used to look up the element name and put that into the code
> generator's output. The mapping could be provided by a Java class that
> reads the mapping from a properties file. The mapping would be
> generated with the shell script mentioned above.
>
> I'guess the best solution would be to augment the xsd files with
> ecore:name annotations to override the names of the types with the
> element names. But maybe there's some easier way?
>>>
>>> Thanks and regards,
>>> Dirk
>
> Thanks for your ever-lasting patience!
> Dirk
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Powered by
FUDForum. Page generated in 0.03184 seconds