Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Element names in the generated XSD file(Generate a XSD from EMF genmodel)
Element names in the generated XSD file [message #1464350] Fri, 07 November 2014 12:59 Go to next message
Inga Ohlsen is currently offline Inga OhlsenFriend
Messages: 2
Registered: November 2014
Junior Member
Hi,

I've a problem with the XSD generated from a given EMF model.
I would like to determine the element and attribute names used in the generated XSD. By default are the element names equal to the associated type names.

Problem description:

My EMF model is generated based on defined XSD, which contains element definitions named as well by lowercase letters as uppercase letters and containing characters such as '_','-'
e.g.
...
<xs:element name="schema_version" type="schema_version"
minOccurs="0" maxOccurs="1" />
...


In the generated EMF model is the obviously names rule for types names with first letter uppercase, for attributes names with first letter lowercase, further the characters '_','-' are omitted, so the corresponding interface is:

public interface SchemaVersion extends EObject { ...


Next up, I generate an XSD file from the EMF genmodel.
I receive an XSD with an element

...
<xsd:element name="SchemaVersion" type="SchemaVersion"/>
...

In consequence, my xml-file that validates the source XSD don't validates the generated XSD.

How can I determine the element names in the generated XSD. What is the solution to handle it?
I would be grateful if you would help me.
Thanks,
Inga
Re: Element names in the generated XSD file [message #1464425 is a reply to message #1464350] Fri, 07 November 2014 14:37 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30366
Registered: July 2009
Senior Member
Inga,

Comments below.

On 07/11/2014 3:03 PM, Inga Ohlsen wrote:
> Hi,
>
> I've a problem with the XSD generated from a given EMF model.
Via the Export Model...? Version type of schema?
> I would like to determine the element and attribute names used in the
> generated XSD.
Determine how? Other than by looking at the result
> By default are the element names equal to the associated type names.
>
> Problem description:
>
> My EMF model is generated based on defined XSD,
If it's based on an XSD why are you saking about generating an XSD?
> which contains element definitions named as well by lowercase letters
> as uppercase letters and containing characters such as '_','-'
> e.g. ..
> <xs:element name="schema_version" type="schema_version"
> minOccurs="0" maxOccurs="1" />
> ..
>
> In the generated EMF model is the obviously names rule for types names
> with first letter uppercase, for attributes names with first letter
> lowercase, further the characters '_','-' are omitted, so the
> corresponding interface is:
>
> public interface SchemaVersion extends EObject { ...
Keep in mind that schema types map to EClassifiers and schema element
and attribute map to EStructuralFeatures...
>
>
> Next up, I generate an XSD file from the EMF genmodel. I receive an
> XSD with an element
> ..
> <xsd:element name="SchemaVersion" type="SchemaVersion"/> ..
Using Export Model...? You should not generally expect an XSD -> Ecore
-> XSD to be a round trip...
>
> In consequence, my xml-file that validates the source XSD don't
> validates the generated XSD.
I get the sense you generated some kind of XMI Schema, which corresponds
to an XMI serialization.
>
> How can I determine the element names in the generated XSD. What is
> the solution to handle it?
Firstly it seems pointless to generate a schema from a model generated
from a schema. You have the original schema. There's no need to
generate it. You've also not be clear what exactly you did to generate
a schema.
> I would be grateful if you would help me.
> Thanks,
> Inga
>
Re: Element names in the generated XSD file [message #1467822 is a reply to message #1464425] Mon, 10 November 2014 10:39 Go to previous messageGo to next message
Inga Ohlsen is currently offline Inga OhlsenFriend
Messages: 2
Registered: November 2014
Junior Member
Hello Ed,
thank You, for Your answer,
I explain what I intend with the source XSD.
My processing is the following.
I generate an EMF model and java classes on base on the XSD-file that I receive from the customer.
I receive from my customer XML files compatible to the input XSD with concrete data, by which I instantiate my model and java objects.

Next, I transform these objects in my own objects, whose have another structure. This objects I can process and
complete by appropriate method with my own data manipulating program (that works with my own model).
At the end I transform my model back to the input data structures then I have to deliver a handled xml to the
customer and this xml must of course validate the source XSD.

The last is not offhand the case, because the element and attribute names in the created xml are not all equal to the names defined in the source XSD
(problems with lowercase/uppercase letters and '-', '_' how described in my topic)

This is briefly the background of my problem.
Regards,
Inga
Re: Element names in the generated XSD file [message #1467857 is a reply to message #1467822] Mon, 10 November 2014 11:14 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30366
Registered: July 2009
Senior Member
Inga,

Comments below.

On 10/11/2014 11:39 AM, Inga Ohlsen wrote:
> Hello Ed,
> thank You, for Your answer, I explain what I intend with the source
> XSD.
> My processing is the following.
> I generate an EMF model and java classes on base on the XSD-file that
> I receive from the customer.
> I receive from my customer XML files compatible to the input XSD with
> concrete data, by which I instantiate my model and java objects.
That's also an Ecore model, but a different one?
>
> Next, I transform these objects in my own objects, whose have another
> structure. This objects I can process and complete by appropriate
> method with my own data manipulating program (that works with my own
> model).
And EMF model?
> At the end I transform my model back to the input data structures then
> I have to deliver a handled xml to the customer and this xml must of
> course validate the source XSD.
I see.
>
> The last is not offhand the case, because the element and attribute
> names in the created xml are not all equal to the names defined in the
> source XSD (problems with lowercase/uppercase letters and '-', '_' how
> described in my topic)
Indeed the Ecore model's named model element names must be well-formed
Java identifiers...
>
> This is briefly the background of my problem.
In general, if you serialize your model instances and that model was
created by importing from XSD but the serialized result doesn't conform
to the XSD, the most likely cause is that you're not using the generated
XyzResourceFactoryImpl to create the resource that's being used to
serialize those instances. So find that generated resource factory
implementation (in the util package of your model), and make sure it's
being used. It's sometimes helpful to generated the *.tests project and
look at the XyzExample.java to see how things should be registered when
writing a stand alone application...
> Regards,
> Inga
>
Re: Element names in the generated XSD file [message #1477889 is a reply to message #1464425] Tue, 18 November 2014 07:37 Go to previous messageGo to next message
Hauke Fuhrmann is currently offline Hauke FuhrmannFriend
Messages: 333
Registered: July 2009
Senior Member
Hi Ed,

maybe I can give some additional idea what we want to achieve:

A customer gave us an XSD which we import to EMF. Now we discard the
original XSD and work only with the EMF tooling to do small changes in
the model. So when the customer expects us to change something in the
XML, we do the changes in EMF and want to generate some XSD, that
validates the new XML.
So what we want to achieve is to migrate from an XSD as the leading
input from which EMF models are generated to EMF as the leading input
from which the XSD is generated.

> Using Export Model...? You should not generally expect an
> XSD -> Ecore > -> XSD to be a round trip...

I would not expect that the generated XSD looks exactly like the
original one, but I would expect that it validates the same XML
instances. And currently it does not.

The original XSD validates the serialized XML that the generated
EMF-Classes and the generated ResourceFactory produce. So far so good.
However, the generated XSD does not validate this XML as Inga stated.

I assumed that all information about XML identifiers is encoded in the
EAnnotations that were added to the EMF Model during XSD import.
However, the generated XSD seems not to respect those. Is there any
additional option we have to set in the generator model?

Cheers,
Hauke


Am 07.11.2014 15:37, schrieb Ed Merks:
> Inga,
>
> Comments below.
>
> On 07/11/2014 3:03 PM, Inga Ohlsen wrote:
>> Hi,
>>
>> I've a problem with the XSD generated from a given EMF model.
> Via the Export Model...? Version type of schema?
>> I would like to determine the element and attribute names used in the
>> generated XSD.
> Determine how? Other than by looking at the result
>> By default are the element names equal to the associated type names.
>>
>> Problem description:
>>
>> My EMF model is generated based on defined XSD,
> If it's based on an XSD why are you saking about generating an XSD?
>> which contains element definitions named as well by lowercase letters
>> as uppercase letters and containing characters such as '_','-'
>> e.g. ..
>> <xs:element name="schema_version" type="schema_version"
>> minOccurs="0" maxOccurs="1" />
>> ..
>>
>> In the generated EMF model is the obviously names rule for types names
>> with first letter uppercase, for attributes names with first letter
>> lowercase, further the characters '_','-' are omitted, so the
>> corresponding interface is:
>>
>> public interface SchemaVersion extends EObject { ...
> Keep in mind that schema types map to EClassifiers and schema element
> and attribute map to EStructuralFeatures...
>>
>>
>> Next up, I generate an XSD file from the EMF genmodel. I receive an
>> XSD with an element
>> ..
>> <xsd:element name="SchemaVersion" type="SchemaVersion"/> ..
> Using Export Model...? You should not generally expect an XSD -> Ecore
> -> XSD to be a round trip...
>>
>> In consequence, my xml-file that validates the source XSD don't
>> validates the generated XSD.
> I get the sense you generated some kind of XMI Schema, which corresponds
> to an XMI serialization.
>>
>> How can I determine the element names in the generated XSD. What is
>> the solution to handle it?
> Firstly it seems pointless to generate a schema from a model generated
> from a schema. You have the original schema. There's no need to generate
> it. You've also not be clear what exactly you did to generate a schema.
>> I would be grateful if you would help me.
>> Thanks,
>> Inga
>>
>
Re: Element names in the generated XSD file [message #1477942 is a reply to message #1477889] Tue, 18 November 2014 08:38 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30366
Registered: July 2009
Senior Member
Hauke,

Comments below.

On 18/11/2014 8:37 AM, Hauke Fuhrmann wrote:
> Hi Ed,
>
> maybe I can give some additional idea what we want to achieve:
>
> A customer gave us an XSD which we import to EMF. Now we discard the
> original XSD and work only with the EMF tooling to do small changes in
> the model.
I see.
> So when the customer expects us to change something in the XML, we do
> the changes in EMF and want to generate some XSD, that validates the
> new XML.
That sounds reasonable.
> So what we want to achieve is to migrate from an XSD as the leading
> input from which EMF models are generated to EMF as the leading input
> from which the XSD is generated.
>
> > Using Export Model...? You should not generally expect an
> > XSD -> Ecore > -> XSD to be a round trip...
>
> I would not expect that the generated XSD looks exactly like the
> original one, but I would expect that it validates the same XML
> instances. And currently it does not.
You're using Export Model?
>
> The original XSD validates the serialized XML that the generated
> EMF-Classes and the generated ResourceFactory produce. So far so good.
> However, the generated XSD does not validate this XML as Inga stated.
Certainly org.eclipse.xsd.ecore.EcoreSchemaBuilder takes extended
metadata annotations into account. But if you're referring to the
schema generated when you set the GenModel's "Generate Schema" property
to true, that produces totally crappy results.
>
> I assumed that all information about XML identifiers is encoded in the
> EAnnotations that were added to the EMF Model during XSD import.
> However, the generated XSD seems not to respect those.
That's why I keep asking if you're using Export Model...
> Is there any additional option we have to set in the generator model?
You have to use Export Model... which is why I keep asking that
question...
>
> Cheers,
> Hauke
>
>
> Am 07.11.2014 15:37, schrieb Ed Merks:
>> Inga,
>>
>> Comments below.
>>
>> On 07/11/2014 3:03 PM, Inga Ohlsen wrote:
>>> Hi,
>>>
>>> I've a problem with the XSD generated from a given EMF model.
>> Via the Export Model...? Version type of schema?
>>> I would like to determine the element and attribute names used in the
>>> generated XSD.
>> Determine how? Other than by looking at the result
>>> By default are the element names equal to the associated type names.
>>>
>>> Problem description:
>>>
>>> My EMF model is generated based on defined XSD,
>> If it's based on an XSD why are you saking about generating an XSD?
>>> which contains element definitions named as well by lowercase letters
>>> as uppercase letters and containing characters such as '_','-'
>>> e.g. ..
>>> <xs:element name="schema_version" type="schema_version"
>>> minOccurs="0" maxOccurs="1" />
>>> ..
>>>
>>> In the generated EMF model is the obviously names rule for types names
>>> with first letter uppercase, for attributes names with first letter
>>> lowercase, further the characters '_','-' are omitted, so the
>>> corresponding interface is:
>>>
>>> public interface SchemaVersion extends EObject { ...
>> Keep in mind that schema types map to EClassifiers and schema element
>> and attribute map to EStructuralFeatures...
>>>
>>>
>>> Next up, I generate an XSD file from the EMF genmodel. I receive an
>>> XSD with an element
>>> ..
>>> <xsd:element name="SchemaVersion" type="SchemaVersion"/> ..
>> Using Export Model...? You should not generally expect an XSD -> Ecore
>> -> XSD to be a round trip...
>>>
>>> In consequence, my xml-file that validates the source XSD don't
>>> validates the generated XSD.
>> I get the sense you generated some kind of XMI Schema, which corresponds
>> to an XMI serialization.
>>>
>>> How can I determine the element names in the generated XSD. What is
>>> the solution to handle it?
>> Firstly it seems pointless to generate a schema from a model generated
>> from a schema. You have the original schema. There's no need to generate
>> it. You've also not be clear what exactly you did to generate a schema.
>>> I would be grateful if you would help me.
>>> Thanks,
>>> Inga
>>>
>>
>
Re: Element names in the generated XSD file [message #1479456 is a reply to message #1477942] Wed, 19 November 2014 12:49 Go to previous message
Hauke Fuhrmann is currently offline Hauke FuhrmannFriend
Messages: 333
Registered: July 2009
Senior Member
Tanks a lot, Ed! We were not aware of an additional option to export the
XSD explicitly via a context menu. This explains a lot.

Cheers,
Hauke

Am 18.11.2014 09:38, schrieb Ed Merks:
> Hauke,
>
> Comments below.
>
> On 18/11/2014 8:37 AM, Hauke Fuhrmann wrote:
>> Hi Ed,
>>
>> maybe I can give some additional idea what we want to achieve:
>>
>> A customer gave us an XSD which we import to EMF. Now we discard the
>> original XSD and work only with the EMF tooling to do small changes in
>> the model.
> I see.
>> So when the customer expects us to change something in the XML, we do
>> the changes in EMF and want to generate some XSD, that validates the
>> new XML.
> That sounds reasonable.
>> So what we want to achieve is to migrate from an XSD as the leading
>> input from which EMF models are generated to EMF as the leading input
>> from which the XSD is generated.
>>
>> > Using Export Model...? You should not generally expect an
>> > XSD -> Ecore > -> XSD to be a round trip...
>>
>> I would not expect that the generated XSD looks exactly like the
>> original one, but I would expect that it validates the same XML
>> instances. And currently it does not.
> You're using Export Model?
>>
>> The original XSD validates the serialized XML that the generated
>> EMF-Classes and the generated ResourceFactory produce. So far so good.
>> However, the generated XSD does not validate this XML as Inga stated.
> Certainly org.eclipse.xsd.ecore.EcoreSchemaBuilder takes extended
> metadata annotations into account. But if you're referring to the schema
> generated when you set the GenModel's "Generate Schema" property to
> true, that produces totally crappy results.
>>
>> I assumed that all information about XML identifiers is encoded in the
>> EAnnotations that were added to the EMF Model during XSD import.
>> However, the generated XSD seems not to respect those.
> That's why I keep asking if you're using Export Model...
>> Is there any additional option we have to set in the generator model?
> You have to use Export Model... which is why I keep asking that question...
>>
>> Cheers,
>> Hauke
>>
>>
>> Am 07.11.2014 15:37, schrieb Ed Merks:
>>> Inga,
>>>
>>> Comments below.
>>>
>>> On 07/11/2014 3:03 PM, Inga Ohlsen wrote:
>>>> Hi,
>>>>
>>>> I've a problem with the XSD generated from a given EMF model.
>>> Via the Export Model...? Version type of schema?
>>>> I would like to determine the element and attribute names used in the
>>>> generated XSD.
>>> Determine how? Other than by looking at the result
>>>> By default are the element names equal to the associated type names.
>>>>
>>>> Problem description:
>>>>
>>>> My EMF model is generated based on defined XSD,
>>> If it's based on an XSD why are you saking about generating an XSD?
>>>> which contains element definitions named as well by lowercase letters
>>>> as uppercase letters and containing characters such as '_','-'
>>>> e.g. ..
>>>> <xs:element name="schema_version" type="schema_version"
>>>> minOccurs="0" maxOccurs="1" />
>>>> ..
>>>>
>>>> In the generated EMF model is the obviously names rule for types names
>>>> with first letter uppercase, for attributes names with first letter
>>>> lowercase, further the characters '_','-' are omitted, so the
>>>> corresponding interface is:
>>>>
>>>> public interface SchemaVersion extends EObject { ...
>>> Keep in mind that schema types map to EClassifiers and schema element
>>> and attribute map to EStructuralFeatures...
>>>>
>>>>
>>>> Next up, I generate an XSD file from the EMF genmodel. I receive an
>>>> XSD with an element
>>>> ..
>>>> <xsd:element name="SchemaVersion" type="SchemaVersion"/> ..
>>> Using Export Model...? You should not generally expect an XSD -> Ecore
>>> -> XSD to be a round trip...
>>>>
>>>> In consequence, my xml-file that validates the source XSD don't
>>>> validates the generated XSD.
>>> I get the sense you generated some kind of XMI Schema, which corresponds
>>> to an XMI serialization.
>>>>
>>>> How can I determine the element names in the generated XSD. What is
>>>> the solution to handle it?
>>> Firstly it seems pointless to generate a schema from a model generated
>>> from a schema. You have the original schema. There's no need to generate
>>> it. You've also not be clear what exactly you did to generate a schema.
>>>> I would be grateful if you would help me.
>>>> Thanks,
>>>> Inga
>>>>
>>>
>>
>
Previous Topic:[CDO] CDO Server unknown DB adapter hsqldb
Next Topic:EPackage with no ResourceSet?
Goto Forum:
  


Current Time: Fri Aug 23 00:09:40 GMT 2019

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

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

Back to the top