EMF parsed xml file replaces double quotes with " symbol [message #1725242] |
Wed, 02 March 2016 00:29  |
Eclipse User |
|
|
|
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 00:30] by Moderator
|
|
|
Re: EMF parsed xml file replaces double quotes with &quot; symbol [message #1725278 is a reply to message #1725242] |
Wed, 02 March 2016 03:57  |
Eclipse User |
|
|
|
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 ?
|
|
|
Powered by
FUDForum. Page generated in 0.05158 seconds