|
|
Re: XMLResource.OPTION_FORMATTED is not working [message #1398529 is a reply to message #1398513] |
Fri, 11 July 2014 07:42 |
Ed Merks Messages: 33113 Registered: July 2009 |
Senior Member |
|
|
Jon,
You've not said much about your model, but if the XSD involves complex
types with mixed content, EMF will print out exactly the white space
that appears in the feature maps corresponding to that mixed content.
Serializing will not alter the model itself to introduce formatting. In
other words, the formatting option only applies for instances of
EClasses for which
org.eclipse.emf.ecore.util.ExtendedMetaData.getContentKind(EClass) is
UNSPECIFIED_CONTENT or ELEMENT_ONLY_CONTENT, i.e., only for the cases
where just white space is allowed and that white space is not meaningful
nor recorded in the model upon deserialization.
On 11/07/2014 9:18 AM, Jon Buck wrote:
> Hi All, hopefully someone may have seen this before....
>
> I have created an ecore and genmodel from an XSD which is all fine
> however when I create a model and try to save it using the generated
> resource factory along with the (XMLResource.OPTION_FORMATTED,
> Boolean.TRUE) option I am getting a single line of text in the file...
>
> Any thoughts anyone?? What am I doing wrong??
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
|
|
|
Re: XMLResource.OPTION_FORMATTED is not working [message #1398697 is a reply to message #1398606] |
Fri, 11 July 2014 12:54 |
Ed Merks Messages: 33113 Registered: July 2009 |
Senior Member |
|
|
Jon,
Comments below.
On 11/07/2014 12:01 PM, Jon Buck wrote:
> Hey Ed, I am using a model generated from Spring's Beans and
> Integration schemas, I haven't altered the generated ecore or genmodel
> in anyway nor do I fully understand that intracies of the schema and
> resulting ecore model...
Fortunately it's all automatic. :-P
> I just had a look at the model after your first reply to see what the
> metadata kind value was set to which as you said may be set to mixed
> which it is...
If you annotated the schema (ecore:mixed="false", you could turn mixed
off, but then non-whitespace mixed content would be ignored.
>
> Apologies for slightly changing the subject here but I am also seeing
> in the serialization that EMF is including elements that are empty!
I'd need more details. Perhaps you've set some feature's value to the
empty string?
> is there anyway to tell EMF to omit empty elements in the resulting
> serialization??
It won't serialize a feature if eIsSet is false, so this suggest you've
set something to the empty string.
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Powered by
FUDForum. Page generated in 0.04128 seconds