Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » EMF parsed xml file replaces double quotes with " symbol
EMF parsed xml file replaces double quotes with " symbol [message #1725242] Wed, 02 March 2016 05:29 Go to next message
Harshad Ghorpade is currently offline Harshad GhorpadeFriend
Messages: 3
Registered: December 2015
Junior Member
I am parsing xml file with EMF modelling, file gets parsed successfully but when I write parsed file to newer xml file(after some modifications) I am seeing that double quote(") symbol gets replaced with " symbol, how to avoid it ?

original xml file content :
<Description>"Prepro Unrecognised preprocessor directive - ignored because it occurs in a FALSE arm of a '#if' group."</Description>


parsed output xml file :
<Description>&quot;Prepro Unrecognised preprocessor directive - ignored because it occurs in a FALSE arm of a '#if' group.&quot;</Description>


Java code I tried to save object :
try {
                        Resource resourceNew = new SevReportResourceFactoryImpl()
                        .createResource(URI.createFileURI("C:\\Users\\user1\\Desktop\\output2.xml"));
                        resourceNew.getContents().add(objCodeAnalysis);
                        Map<String,Object> options = new HashMap<String, Object>();
                        options.put(XMIResource.OPTION_ENCODING, "ISO-8859-1");
                        options.put(XMIResource.OPTION_LAX_WILDCARD_PROCESSING,Boolean.TRUE);
                        resourceNew.save(options);
                        } catch (IOException e) {
                            e.printStackTrace();
                        }


Am I missing something while writing the file ?

[Updated on: Wed, 02 March 2016 05:30]

Report message to a moderator

Re: EMF parsed xml file replaces double quotes with &amp;quot; symbol [message #1725278 is a reply to message #1725242] Wed, 02 March 2016 08:57 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33142
Registered: July 2009
Senior Member
Harshad,

It just does that by default, though arguably that's not necessary. In
any case, you should expect the in-memory value to be preserved across
serialization, not the serialization details themselves. It's always
valid to use an entity instead of the literal character and all XML
processors will transform it to the correct literal character. If you
wanted to specialize this, you'd have to specialize the behavior of
org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.Escape.convertText(String).


On 02.03.2016 06:29, Harshad Ghorpade wrote:
> I am parsing xml file with EMF modelling, file gets parsed
> successfully but when I write parsed file to newer xml file(after some
> modifications) I am seeing that double quote(") symbol gets replaced
> with " symbol, how to avoid it ?
>
> original xml file content :
> <Description>"Prepro Unrecognised preprocessor directive - ignored
> because it occurs in a FALSE arm of a '#if' group."</Description>
>
> parsed output xml file :
> <Description>"Prepro Unrecognised preprocessor directive - ignored
> because it occurs in a FALSE arm of a '#if' group."</Description>
>
> Java code I tried to save object :
> try {
> Resource resourceNew = new
> SevReportResourceFactoryImpl()
> .createResource(URI.createFileURI("C:\\Users\\user1\\Desktop\\output2.xml"));
> resourceNew.getContents().add(objQACCodeAnalysis);
> Map<String,Object> options = new
> HashMap<String, Object>();
> options.put(XMIResource.OPTION_ENCODING,
> "ISO-8859-1");
> options.put(XMIResource.OPTION_LAX_WILDCARD_PROCESSING,Boolean.TRUE);
> resourceNew.save(options);
> } catch (IOException e) {
> e.printStackTrace();
> }
>
> Am I missing something while writing the file ?


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:Using EObject.eGet to retrieve the value of EReference feature
Next Topic:[XCORE] is there a way to use &quot;break&quot; in a for loop defined in an xcore file?
Goto Forum:
  


Current Time: Fri Apr 26 09:49:20 GMT 2024

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

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

Back to the top