Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » XML comments missed
XML comments missed [message #496151] Mon, 09 November 2009 06:37 Go to next message
DartPeng is currently offline DartPengFriend
Messages: 7
Registered: July 2009
Junior Member
Hi all,

There is a problem feazes me:

When I save the EMF model to XML text , the original comments of XML file were missed.

I change the metadata (which is "elementOnly" type) of some EMF model in ***PackageImpl to be "mixed" , the original comments can be saved , but their positions were changed...

e,g. :

Original XML :
<!-- comments NO1 -->
<element /></element>
<!-- comments NO2 -->
<element/></element>

Generated by EMF model:
<!-- comments NO1 -->
<!-- comments NO2 -->
<element /></element>
<element/></element>

Please help me , thank you !

- Dart
Re: XML comments missed [message #496165 is a reply to message #496151] Mon, 09 November 2009 08:53 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 26279
Registered: July 2009
Senior Member
Dart,

Comments below.

DartPeng wrote:
> Hi all,
>
> There is a problem feazes me:
>
> When I save the EMF model to XML text , the original comments of XML
> file were missed.
>
> I change the metadata (which is "elementOnly" type) of some EMF model
> in ***PackageImpl to be "mixed" , the original comments can be saved ,
> but their positions were changed...
How much of the metadata did you change? Specifically are the element
feature marked derived so they are delegating their storage to the
feature map? Try changing the schema itself to use mixed="true" so you
can be sure you're getting the correct annotations.
>
> e,g. :
>
> Original XML :
> <!-- comments NO1 -->
> <element /></element>
> <!-- comments NO2 -->
> <element/></element>
>
> Generated by EMF model: <!-- comments NO1 -->
> <!-- comments NO2 -->
> <element /></element>
> <element/></element>
>
> Please help me , thank you !
>
> - Dart
Re: XML comments missed [message #496449 is a reply to message #496165] Tue, 10 November 2009 07:40 Go to previous messageGo to next message
DartPeng is currently offline DartPengFriend
Messages: 7
Registered: July 2009
Junior Member
Thank you !

I did what you said and the XML comments can be keep well now.

But it's hard work for me , because I need to re-generate all EMF models code , I'm afraid that if the codes changed , many bugs will occur.

I just want to keep the XML comment (CDATA , Text) , is there any way to resolve that without re-generating EMF models?

Anyway , Thank you again!
Re: XML comments missed [message #496528 is a reply to message #496449] Tue, 10 November 2009 12:40 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 26279
Registered: July 2009
Senior Member
Dart,

Comments below.

DartPeng wrote:
> Thank you !
>
> I did what you said and the XML comments can be keep well now.
> But it's hard work for me , because I need to re-generate all EMF
> models code , I'm afraid that if the codes changed , many bugs will
> occur.
How are you defining your Ecore model?
>
> I just want to keep the XML comment (CDATA , Text) , is there any way
> to resolve that without re-generating EMF models?
No. For those things to be stored as part of the model instance, the
model needs to define a mixed feature map...
>
> Anyway , Thank you again!
Re: XML comments missed [message #621573 is a reply to message #496165] Tue, 10 November 2009 07:40 Go to previous messageGo to next message
DartPeng is currently offline DartPengFriend
Messages: 7
Registered: July 2009
Junior Member
Thank you !

I did what you said and the XML comments can be keep well now.

But it's hard work for me , because I need to re-generate all EMF models code , I'm afraid that if the codes changed , many bugs will occur.

I just want to keep the XML comment (CDATA , Text) , is there any way to resolve that without re-generating EMF models?

Anyway , Thank you again!
Re: XML comments missed [message #621575 is a reply to message #621573] Tue, 10 November 2009 12:40 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 26279
Registered: July 2009
Senior Member
Dart,

Comments below.

DartPeng wrote:
> Thank you !
>
> I did what you said and the XML comments can be keep well now.
> But it's hard work for me , because I need to re-generate all EMF
> models code , I'm afraid that if the codes changed , many bugs will
> occur.
How are you defining your Ecore model?
>
> I just want to keep the XML comment (CDATA , Text) , is there any way
> to resolve that without re-generating EMF models?
No. For those things to be stored as part of the model instance, the
model needs to define a mixed feature map...
>
> Anyway , Thank you again!
Re: XML comments missed [message #714790 is a reply to message #496528] Thu, 11 August 2011 14:02 Go to previous messageGo to next message
Missing name Mising name is currently offline Missing name Mising nameFriend
Messages: 11
Registered: July 2011
Junior Member
I have a problem which is related to this in some kind.
I have a XSD in which the complexType´s are elementOnly. So if I generate a model and editors out of it, I do not have the opportunity to set comments, process information, CDATA and text within the EMF editor. This is ok. But what is not ok is that when there are xml comments <!-- --> in the underlying file and if I load, edit and save the file with the EMF editor, the comments are gone in the xml...
I have a validator, which use the XSD to validate the underlying file (not the emf validator). For this validator comments <!-- -->, PI <? ?> and CDATA <![CDATA[]]> are ok within an elementOnly complexType. Plain text is not allowed.
If I change the XSD (<xs:complexType name="Wurst" mixed="true">), the generated editor is capable of adding and editing these xml markup elements. But its also possible to add plain text. I dont want that.

My questions now: Who is wrong? The validator which is allowing markup elements in elementOnly complex types? Or EMF in not allowing/enabling xml markup elements in elementOnly types? Why the emf editor even open these files with markup elements in the wrong place?
Is there nothing inbetween elementOnly and mixed="true"? I want comments, process information and CDATA, but no plain text.
I am really confused, please help me out...






Re: XML comments missed [message #714821 is a reply to message #714790] Thu, 11 August 2011 14:52 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 26279
Registered: July 2009
Senior Member
Comments below.

On 11/08/2011 7:02 AM, fkluthe wrote:
> I have a problem which is related to this in some kind.
> I have a XSD in which the complexType´s are elementOnly.
So no mixed content.
> So if I generate a model and editors out of it, I do not have the
> opportunity to set comments, process information, CDATA and text
> within the EMF editor.
Indeed, it's just white space and isn't recorded outside of mixed
content. There is place to record it in the model in this case.
> This is ok. But what is not ok is that when there are xml comments
> <!-- --> in the underlying file and if I load, edit and save the file
> with the EMF editor, the comments are gone in the xml...
That's what happens with white space, it's not preserved. Meaningful
information should be part of the schema/model.
> I have a validator, which use the XSD to validate the underlying file
> (not the emf validator). For this validator comments <!-- -->, PI <?
> ?> and CDATA <![CDATA[]]> are ok within an elementOnly complexType.
They're always okay anywhere.
> Plain text is not allowed.
> If I change the XSD (<xs:complexType name="Wurst" mixed="true">), the
> generated editor is capable of adding and editing these xml markup
> elements. But its also possible to add plain text. I dont want that.
It's also possible to avoid it, even though it's possible.
>
> My questions now: Who is wrong?
Sounds like something is allowing mixed content where it's not normally
allowed.
> The validator which is allowing markup elements in elementOnly complex
> types?
White space (comments and processing instructions) are allowed
anywhere. Mixed content, including CDATA, is only allowed where mixed
content is allowed.
> Or EMF in not allowing/enabling xml markup elements in elementOnly types?
EMF just uses SAX so that's all very permissive allowing anything that's
well formed. EMF will happily ignore mixed content when it's not
expecting it.
> Why the emf editor even open these files with markup elements in the
> wrong place?
SAX allows it and EMF happily overlooks it. It's possible to configure
the SAX parser so that it's a validating parser and will strictly adhere
to what's allowed in your schema.
> Is there nothing inbetween elementOnly and mixed="true"?
No.
> I want comments, process information and CDATA, but no plain text.
CDATA and plain text are semantically identical. Nothing in XML Schema
will allow one but not the other.
> I am really confused, please help me out...
If you must, you can specialize XMLHandler to allow or disallow specific
things coming in through SAX.
>
>
>
>
>
>
>
Re: XML comments missed [message #715072 is a reply to message #714821] Fri, 12 August 2011 09:49 Go to previous messageGo to next message
Missing name Mising name is currently offline Missing name Mising nameFriend
Messages: 11
Registered: July 2011
Junior Member
Thx for your reply.
"CDATA and plain text are semantically identical." Oh I did not realize that; i played around with different content and just put in "<![CDATA[]]>" - without any content. Of course this was not criticize by the validator, so I thought it was allowed in elementOnly complex types...

"Meaningful information should be part of the schema/model." True true... but actually more than one party is involved. I personally think this would be the best solution but I also doubt we agree on that.
The thing is, I have to persist the given xml-comments. While searching for an easy way to do this I came across this thread and try out the mixed="true" thing. By adding this to the model, EMF will generate all I need (persist the comments, adding comments as childnodes in the editor). Now I could make it impossible for the user to insert CDATA into the complexTypes but in return the changed XSD, which is the basis for validation, will allow CDATA; not necessarily added on my side.
Using 2 different XSD´s? One for code generation one for validation? Possible but messy with reference to maintainability.

Anyway, thanks for the support. I like emf and you have done great in the past. I know you have to accommodate a number of things, but one thing I would suggest is that emf should offer the opportunity to add and persist xml-comments and process information with the editor by default/or configuration - since they are allowed anywhere in xml anyway. One thing I quite not understand is why the opportunity to add comments and PI comes with the mixed="true" attribute - it only gives indication that there is character data allowed to appear between the child elements. Confused
Re: XML comments missed [message #715159 is a reply to message #715072] Fri, 12 August 2011 14:58 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 26279
Registered: July 2009
Senior Member
Comments below.

On 12/08/2011 2:49 AM, fkluthe wrote:
> Thx for your reply.
> "CDATA and plain text are semantically identical." Oh I did not
> realize that; i played around with different content and just put in
> "<![CDATA[]]>" - without any content. Of course this was not criticize
> by the validator, so I thought it was allowed in elementOnly complex
> types...
When it just expands to white space (or the empty string), I suppose
it's okay...
>
> "Meaningful information should be part of the schema/model." True
> true... but actually more than one party is involved. I personally
> think this would be the best solution but I also doubt we agree on that.
The parties should have it explained to them that in general, they
should expect tools not to preserve white space.
> The thing is, I have to persist the given xml-comments. While
> searching for an easy way to do this I came across this thread and try
> out the mixed="true" thing. By adding this to the model, EMF will
> generate all I need (persist the comments, adding comments as
> childnodes in the editor). Now I could make it impossible for the user
> to insert CDATA into the complexTypes but in return the changed XSD,
> which is the basis for validation, will allow CDATA; not necessarily
> added on my side. Using 2 different XSD´s? One for code generation one
> for validation? Possible but messy with reference to maintainability.
A bit messy, but life is a compromise.
>
> Anyway, thanks for the support. I like emf and you have done great in
> the past. I know you have to accommodate a number of things, but one
> thing I would suggest is that emf should offer the opportunity to add
> and persist xml-comments and process information with the editor by
> default/or configuration - since they are allowed anywhere in xml
> anyway. One thing I quite not understand is why the opportunity to add
> comments and PI comes with the mixed="true" attribute - it only gives
> indication that there is character data allowed to appear between the
> child elements. :?
Part of the problem comes down to "what in the model will store the
data." In the case of mixed content, the opportunity is perfect. We
have a feature for storing the data, i.e., the mixed feature map. That
feature is perfect for preserving the mixed order between the element
content and the "non-content". In all other cases, there's no place in
the model to store the data and even if there was a special feature, it
wouldn't preserve the mixed order.
Previous Topic:EMF.Edit Updating Lists
Next Topic:End user oriented EMF Parsng/Reporting/Transforming
Goto Forum:
  


Current Time: Thu Dec 18 09:33:25 GMT 2014

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

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