EMF parsed xml file replaces double quotes with " symbol [message #1725242] |
Wed, 02 March 2016 05:29 |
Harshad Ghorpade 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>"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(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 &quot; symbol [message #1725278 is a reply to message #1725242] |
Wed, 02 March 2016 08:57 |
Ed Merks Messages: 33218 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/
|
|
|
Powered by
FUDForum. Page generated in 0.02883 seconds