Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Handle comments in xml file on Resource load/save
Handle comments in xml file on Resource load/save [message #417315] Wed, 05 March 2008 09:30 Go to next message
Chetan Kumar is currently offline Chetan KumarFriend
Messages: 70
Registered: July 2009
Member
Hello,

I have a schema based EMF model and i use Resource load and save to
export and import an XML file which is schema complaint.

Problem is, some of the XML files have a lot of information (useful when
just viewing the xml file) in the form of comments.

The comments may carry some versioning information also, however these
comments are not required for me from the code/ model perspective. But,
when I save back the xml file after say, a few changes ... all these XML
comments are gone.

I have tried using the XMLResource.OPTION_USE_LEXICAL_HANDLER, and
OPTION_EXTENDED_META_DATA options but in vain. Am I missing something ?
Any help will be very useful.

cheers,
Chetan Kumar
Re: Handle comments in xml file on Resource load/save [message #417316 is a reply to message #417315] Wed, 05 March 2008 10:04 Go to previous messageGo to next message
Ron Bermejo is currently offline Ron BermejoFriend
Messages: 30
Registered: July 2009
Member
Hi,

If you want to save these XML comments then I think you will need to set
mixed="true" to the appropriate complexType in your schema. The downside
to this is that your generated code for this type will use FeatureMaps for
its features, instead of the straightforward or more "natural-looking" API
:)

Hth,
Ron
Re: Handle comments in xml file on Resource load/save [message #417320 is a reply to message #417316] Wed, 05 March 2008 11:34 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33142
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------020901090505010601000109
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 7bit

Ron,

It's kind of horrible but the only way right now. It makes me wonder if
an option that populates the comments into this map (the same way as
unrecognized content can be handled) might be useful to a significant
number of clients:

| /**
* Returns the map with {@link EObject} as keys and corresponding {@link org.eclipse.emf.ecore.xml.type.AnyType}s as the values.
* It's used to record unrecognized elements and attributes.
*/
Map<EObject, AnyType> getEObjectToExtensionMap();|


Ron Bermejo wrote:
> Hi,
>
> If you want to save these XML comments then I think you will need to
> set mixed="true" to the appropriate complexType in your schema. The
> downside to this is that your generated code for this type will use
> FeatureMaps for its features, instead of the straightforward or more
> "natural-looking" API :)
>
> Hth,
> Ron
>


--------------020901090505010601000109
Content-Type: text/html; charset=ISO-8859-15
Content-Transfer-Encoding: 8bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-15"
http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Ron,<br>
<br>
It's kind of horrible but the only way right now.


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:Default values for Attributes not Serialized
Next Topic:Unable to View contents in EMF Editor
Goto Forum:
  


Current Time: Fri Apr 26 10:01:19 GMT 2024

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

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

Back to the top