Bug 1014646 - Editing of switchyard.xml by visual editor removes comments
Summary: Editing of switchyard.xml by visual editor removes comments
Keywords:
Status: NEW
Alias: None
Product: JBoss Fuse Service Works 6
Classification: JBoss
Component: SwitchYard Editor
Version: 6.0.0 GA
Hardware: Unspecified
OS: Unspecified
medium
high
Target Milestone: ---
: ---
Assignee: Rob Cernich
QA Contact: Matej Melko
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2013-10-02 13:21 UTC by Tomas Rohovsky
Modified: 2023-05-15 19:52 UTC (History)
4 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed:
Type: Bug
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Issue Tracker SWITCHYARD-1710 0 Major Open Editing of switchyard.xml by visual editor removes comments 2014-08-21 02:49:26 UTC

Description Tomas Rohovsky 2013-10-02 13:21:16 UTC
Description of problem:
Editing of switchyard.xml by visual editor removes comments.

Version-Release number of selected component (if applicable):

1.1.0.v20130912-2244-H393-M2

How reproducible:


Steps to Reproduce:
1. Create a comment in switchyard.xml and save.
2. Modify something by visual editor.

Actual results:
The comment is removed.

Expected results:
The comment is present.

Additional info:

Comment 2 Rob Cernich 2013-10-03 14:20:31 UTC
Brian,

Can you investigate this?  I'm not sure if it is possible for us to support this using EMF.  For the time being, I'd look at two possibilities:
1. See if there is an option that can be set on the resource/resource factory that will allow unsupported elements, including comments to be round tripped.
2. As a possible workaround, see if a "documentation" element is more feasible (you'll have to look at the schemas).

Thanks,
Rob

Comment 3 Brian Fitzpatrick 2013-10-03 14:27:41 UTC
Yup. Will take a look. On a cursory search, it looks like there is an option we can use in the XMLResource (OPTION_USE_LEXICAL_HANDLER) that may help preserve comments (http://download.eclipse.org/modeling/emf/emf/javadoc/2.7.0/org/eclipse/emf/ecore/xmi/XMLResource.html).

Comment 4 Brian Fitzpatrick 2013-10-03 17:25:28 UTC
Unfortunately we already seem to be using that in all our generated EMF resource factories, so that's not the issue.

Comment 5 Brian Fitzpatrick 2013-10-03 18:09:11 UTC
Ok... I found a possible fix, but it's not pretty.

Based on this forum post from 2008 (http://www.eclipsezone.com/eclipse/forums/t115996.html) I added 'mixed="true"' (http://www.w3schools.com/schema/schema_complex_mixed.asp) to the switchyard-v1.xsd schema, rebuilt an ecore, and merged the change with the existing config.switchyard.ecore model. 

Doing that, I was able to put a comment inside the <switchyard> element via a text editor, go in via the multi-page SY editor and change the model, save it, and have it persist. 

It completely hoses the nice clean structure of the XML when you do this, leading to some really messy XML formatting in the file. But it does work. 

Unfortunately this would require regenerating every single model across the board to add the "mixed" attribute to all the complex types we want to allow comments in, otherwise they get stripped out.

Comment 6 Brian Fitzpatrick 2013-10-03 18:32:23 UTC
That said, modifying the schema is a bad idea. We may be able to do this in the ecore itself, but that may also have bad ripples.

As a workaround, <sca:documentation> elements can be placed in various parts of the switchyard.xml file without causing too much trouble.

We could look into adding a way in the editor to view/modify these documentation elements on a variety of places where supported (any element that extends CommonExtensionBase). And we may want to have the SwitchYard root element extend CommonExtensionBase as well to get documentation at the base level of the config.

This is very much an enhancement at this point obviously.

And it's definitely a bug that we don't preserve xml comments.

Comment 7 Keith Babo 2013-10-03 19:02:34 UTC
Agree with Brian's assessment here.  Including comments introduces risk and negative impact from a usability standpoint (formatting) with questionable value to end users.  There are <sca:documentation> elements available, but it would make even more sense for users to record notes in the design-time repository which is also packaged with FSW.

This should definitely stick around as a functional gap / enhancement though.


Note You need to log in before you can comment on or make changes to this bug.