Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » XML Parsing fails due to special character
XML Parsing fails due to special character [message #1781051] Wed, 31 January 2018 20:45 Go to next message
Deepika Logani is currently offline Deepika LoganiFriend
Messages: 1
Registered: January 2018
Junior Member
In my application if any there is any special character and if I try to save file then parsing fails and nothing get saved(size of file is 1KB). If I use property
XMLResource.OPTION_SKIP_ESCAPE to skpi processing of values having special character, which leads to data loss.
Can someone help me overcome this?
Re: XML Parsing fails due to special character [message #1781323 is a reply to message #1781051] Tue, 06 February 2018 04:52 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30804
Registered: July 2009
Senior Member
You've not mentioned what's special about the character, so I can only guess. Of course you should specifying an character encoding that can encode all your characters, i.e., org.eclipse.emf.ecore.xmi.XMLResource.setEncoding(String) with the value "UTF-8" in your resource factory. You should use OPTION_SKIP_ESCAPE only if there are known to be no characters that need escaping. You should use OPTION_SKIP_ESCAPE_URI mapped to FALSE if your URIs for cross references contain characters that need escaping; but best you avoid that by not using resources with things like <, >, or & in the URI. And finally, there are the control characters, <= 0x1F. XML 1.0 cannot serialize many of these, but XML 1.1 can, so you could use org.eclipse.emf.ecore.xmi.XMLResource.setXMLVersion(String) with the value 1.1 to serialize these. But no version of XML can serialize the null character 0x0. If you need that , you'll have to define your own EDataType (that wraps java.util.String), and does encoding and decoding.
Re: XML Parsing fails due to special character [message #1781331 is a reply to message #1781323] Tue, 06 February 2018 07:19 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 6566
Registered: July 2009
Senior Member

EMF generally does a good job of XML encoding, however there are a few scenarios where the encoding responsibility is pushed back to the user since enforcement by EMF would impose a disproportionate cost on normal use. xmi:id values are one example of this; xmi:id values must be legal without further encoding.

Without an example of your bad character we can only guess.


Ed Willink
Previous Topic:[CDO] - CDOResource
Next Topic:New Eclipse User
Goto Forum:

Current Time: Sun Jan 19 19:03:22 GMT 2020

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

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

Back to the top