Skip to main content



      Home
Home » Modeling » EMF » handling XML comment
handling XML comment [message #380882] Mon, 08 December 2003 17:11 Go to next message
Eclipse UserFriend
I'm well into creating a custom editor for XML files based on a schema
of an existing server applicaiton. Many of these XML files exist already
and were created by hand by the application users. Some have copyright
or major design comments before the first element which must be
preserved when user switch over to my tool for editing the files.
Comments in the remainder of the file can be discarded for now (but they
need to be handled by my tool in the future).

I'm using the load/save implemenations generated by the EMF tools. It
looks to me like XML comments are not handled/supported by the core EMF
classes? Hopefully I've missed something.

I'm looking for suggestions on how I might deal with this issue now
(finding and preserving the comments before the first element) and if
EMF can help me out in any way.

Also, are there plans for EMF to provide support for comments in the
future? Would it make sense to allow packaging comments with the next
element found and put them its EObject and make them accessible with
something like "myEobject.getComments() and myEObject.setComments"?

Mark
Re: handling XML comment [message #380884 is a reply to message #380882] Mon, 08 December 2003 20:11 Go to previous messageGo to next message
Eclipse UserFriend
Mark,

EMF 2.0 will support mixed content, including special lexical handlers for
CDATA and comments. Comments in the root are recorded as the mixed content
of a special document root EClass that is analogous to an
org.w3c.dom.Document.


Mark Brodhun wrote:

> I'm well into creating a custom editor for XML files based on a schema
> of an existing server applicaiton. Many of these XML files exist already
> and were created by hand by the application users. Some have copyright
> or major design comments before the first element which must be
> preserved when user switch over to my tool for editing the files.
> Comments in the remainder of the file can be discarded for now (but they
> need to be handled by my tool in the future).
>
> I'm using the load/save implemenations generated by the EMF tools. It
> looks to me like XML comments are not handled/supported by the core EMF
> classes? Hopefully I've missed something.
>
> I'm looking for suggestions on how I might deal with this issue now
> (finding and preserving the comments before the first element) and if
> EMF can help me out in any way.
>
> Also, are there plans for EMF to provide support for comments in the
> future? Would it make sense to allow packaging comments with the next
> element found and put them its EObject and make them accessible with
> something like "myEobject.getComments() and myEObject.setComments"?
>
> Mark
Re: handling XML comment [message #398318 is a reply to message #380884] Thu, 02 February 2006 07:03 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

how has the topic of XML comments developed so far?

I added a comment to a XML file using a texteditor. Then I opened the
file with the EMF editor, changed something and saved it again. The
comment was gone.

I didn't find anything about comments neither in the genmodel
properties, nor in the book nor when I googled for it (though I didn't
try that one hard).

Is it possible to preserve comments in XML files? I mean not only before
the first element, but somewhere in the document. If this is not
supported by EMF, do you think it would be hard to implement?

I read something in another post about implementing my own XMLSaveImpl
class. But actually the problem is not only to save the comments but to
represent the comments in the model somewhere, right? I mean, I don't
want to refer to the comments in the editor or somewhere else in the
model, but I have to attach the comments to the according element to be
able to save them later somehow. I guess it's not a trivial task, is it?

Regards,

Oliver

Ed Merks wrote:
> Mark,
>
> EMF 2.0 will support mixed content, including special lexical handlers for
> CDATA and comments. Comments in the root are recorded as the mixed content
> of a special document root EClass that is analogous to an
> org.w3c.dom.Document.
>
>
> Mark Brodhun wrote:
>
>
>>I'm well into creating a custom editor for XML files based on a schema
>>of an existing server applicaiton. Many of these XML files exist already
>>and were created by hand by the application users. Some have copyright
>>or major design comments before the first element which must be
>>preserved when user switch over to my tool for editing the files.
>>Comments in the remainder of the file can be discarded for now (but they
>>need to be handled by my tool in the future).
>>
>>I'm using the load/save implemenations generated by the EMF tools. It
>>looks to me like XML comments are not handled/supported by the core EMF
>>classes? Hopefully I've missed something.
>>
>>I'm looking for suggestions on how I might deal with this issue now
>>(finding and preserving the comments before the first element) and if
>>EMF can help me out in any way.
>>
>>Also, are there plans for EMF to provide support for comments in the
>>future? Would it make sense to allow packaging comments with the next
>>element found and put them its EObject and make them accessible with
>>something like "myEobject.getComments() and myEObject.setComments"?
>>
>>Mark
>
>
Re: handling XML comment [message #398319 is a reply to message #398318] Thu, 02 February 2006 07:38 Go to previous message
Eclipse UserFriend
Oliver,

In order for the parser not to toss away the comments, you need to use
the XMLResource.OPTION_USE_LEXICAL_HANDLER option. If you use this
option, anywhere that mixed content is allowed (as in an EClass produced
from a complex type with mixed="true"), EMF will be able to preserve
those comments.


Oliver Olesen wrote:

> Hi,
>
> how has the topic of XML comments developed so far?
>
> I added a comment to a XML file using a texteditor. Then I opened the
> file with the EMF editor, changed something and saved it again. The
> comment was gone.
>
> I didn't find anything about comments neither in the genmodel
> properties, nor in the book nor when I googled for it (though I didn't
> try that one hard).
>
> Is it possible to preserve comments in XML files? I mean not only
> before the first element, but somewhere in the document. If this is
> not supported by EMF, do you think it would be hard to implement?
>
> I read something in another post about implementing my own XMLSaveImpl
> class. But actually the problem is not only to save the comments but
> to represent the comments in the model somewhere, right? I mean, I
> don't want to refer to the comments in the editor or somewhere else in
> the model, but I have to attach the comments to the according element
> to be able to save them later somehow. I guess it's not a trivial
> task, is it?
>
> Regards,
>
> Oliver
>
> Ed Merks wrote:
>
>> Mark,
>>
>> EMF 2.0 will support mixed content, including special lexical
>> handlers for
>> CDATA and comments. Comments in the root are recorded as the mixed
>> content
>> of a special document root EClass that is analogous to an
>> org.w3c.dom.Document.
>>
>>
>> Mark Brodhun wrote:
>>
>>
>>> I'm well into creating a custom editor for XML files based on a schema
>>> of an existing server applicaiton. Many of these XML files exist
>>> already
>>> and were created by hand by the application users. Some have copyright
>>> or major design comments before the first element which must be
>>> preserved when user switch over to my tool for editing the files.
>>> Comments in the remainder of the file can be discarded for now (but
>>> they
>>> need to be handled by my tool in the future).
>>>
>>> I'm using the load/save implemenations generated by the EMF tools. It
>>> looks to me like XML comments are not handled/supported by the core EMF
>>> classes? Hopefully I've missed something.
>>>
>>> I'm looking for suggestions on how I might deal with this issue now
>>> (finding and preserving the comments before the first element) and if
>>> EMF can help me out in any way.
>>>
>>> Also, are there plans for EMF to provide support for comments in the
>>> future? Would it make sense to allow packaging comments with the next
>>> element found and put them its EObject and make them accessible with
>>> something like "myEobject.getComments() and myEObject.setComments"?
>>>
>>> Mark
>>
>>
>>
Previous Topic:[Announce] EMF 2.2.0 I200602020000 is available
Next Topic:ExceptionInInitializerError in ModelWizard
Goto Forum:
  


Current Time: Tue Nov 04 08:47:03 EST 2025

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

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

Back to the top