Skip to main content



      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 00:29 Go to next message
Eclipse UserFriend
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 00:30] by 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 03:57 Go to previous message
Eclipse UserFriend
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 ?
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: Wed Jul 23 16:45:07 EDT 2025

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

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

Back to the top