Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Required attributes missing in generated XML from EMF editor
Required attributes missing in generated XML from EMF editor [message #418761] Mon, 28 April 2008 21:13 Go to next message
Eclipse UserFriend
Originally posted by: roberto.milev.gmail.com

Hi,

I have a EMF model that I generated form a XML schema. In the schema I
have a bunch of required attributes (use="required") for my elements. I
was able to generate an editor from the .genmodel. However unless I
explicitly change the values of each attribute they are not included in
the XML produced by the editor. (I guess they get defaults, but
nevertheless this produces XML that does not comply to the XML Schema)


Is there a way to model this, so that all the required attributes are
always included in the result XML?

Thank you,
Roberto
Re: Required attributes missing in generated XML from EMF editor [message #418764 is a reply to message #418761] Mon, 28 April 2008 22:07 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
Roberto,

Making a feature required is the same as saying that the user must
explicitly set a value. You'll note that in XML Schema you can give a
feature a default value, but in that case, you can't also make it
required. You might want to fiddle with
XMLResource.OPTION_KEEP_DEFAULT_CONTENT to force default values to be
serialized...


Roberto Milev wrote:
> Hi,
>
> I have a EMF model that I generated form a XML schema. In the schema I
> have a bunch of required attributes (use="required") for my elements.
> I was able to generate an editor from the .genmodel. However unless I
> explicitly change the values of each attribute they are not included
> in the XML produced by the editor. (I guess they get defaults, but
> nevertheless this produces XML that does not comply to the XML Schema)
>
>
> Is there a way to model this, so that all the required attributes are
> always included in the result XML?
>
> Thank you,
> Roberto


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Required attributes missing in generated XML from EMF editor [message #418778 is a reply to message #418764] Tue, 29 April 2008 13:40 Go to previous message
Eclipse UserFriend
Originally posted by: roberto.milev.gmail.com

Ed,

Setting defaults in the XML schema, and
XMLResource.OPTION_KEEP_DEFAULT_CONTENT to true did exactly what I
wanted. Thank you!

Ed Merks wrote:
> Roberto,
>
> Making a feature required is the same as saying that the user must
> explicitly set a value. You'll note that in XML Schema you can give a
> feature a default value, but in that case, you can't also make it
> required. You might want to fiddle with
> XMLResource.OPTION_KEEP_DEFAULT_CONTENT to force default values to be
> serialized...
>
>
> Roberto Milev wrote:
>> Hi,
>>
>> I have a EMF model that I generated form a XML schema. In the schema I
>> have a bunch of required attributes (use="required") for my elements.
>> I was able to generate an editor from the .genmodel. However unless I
>> explicitly change the values of each attribute they are not included
>> in the XML produced by the editor. (I guess they get defaults, but
>> nevertheless this produces XML that does not comply to the XML Schema)
>>
>>
>> Is there a way to model this, so that all the required attributes are
>> always included in the result XML?
>>
>> Thank you,
>> Roberto
Previous Topic:EcoreItemProviderFactory and "isFactoryForType"
Next Topic:XML Schema vs. XML Schema for XMI
Goto Forum:
  


Current Time: Thu Mar 28 19:45:07 GMT 2024

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

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

Back to the top