All characters with code greater than 7f are written to XML attribute value as character literal.
This is because XmlWriter has wrong checking condition:
if ((currentChar > 0x7f) || !isValidXmlChar(currentChar)) { entity = "&#" + String.valueOf((int) currentChar) + ";"; }
should be
if ((currentChar > 0x7f) && !isValidXmlChar(currentChar)) { entity = "&#" + String.valueOf((int) currentChar) + ";"; }
Another problem is that isValidXmlChar() parameter is 'char' so third condition in this method is always false. Parameter shoud be changed to int. This is not complete solution for the problem buf fixes isValidXmlChar() method.
Thanks for reporting.
I extracted the switch to a method to help with testing this and pushed it.
Since you have the context and situation that causes the problem(s), would you mind taking this issue further and writing tests to prove the issues along with the fixes and then providing them as a patch or merge request please?
I've created test, fix and already placed merge request.
Please rebase from master so the merge is clean.
Do you need more time to resolve further or did you give up on this one?
I've rebased from master and provided new pull request. Did you see it?
Perhaps you didn't see my comment on it:
Thanks. I encounter this problem with this commit merged:
Failed tests:
XmlWriterTest.testEncodedXmlChar:166 expected:<<COLUMN1 ATTR="<span><span>[klzzwxh:0000text1klzzwxh:0001text2klzzwxh:0002text3klzzwxh:0003" klzzwxh:0000klzzwxh:0004text1klzzwxh:0001#xklzzwxh:0007A;text2klzzwxh:0005text3klzzwxh:0006]<="" span=""><="" span=""></COLUMN1>
but was:<<COLUMN1 ATTR="<span><span>[«text1klzzwxh:0012text2klzzwxh:0013text3«" klzzwxh:0003«text1klzzwxh:0014text2klzzwxh:0015text3«]<="" span=""><="" span=""></COLUMN1>
Does it pass for you?
Sorry. I've missed it.
Expected value in this test was wrong because it contained a valid XML char
(174=0xAE) in encoded form.
I've fixed it too.
Another point is that method convertCharacterToEntity() encodes '\r', '\n'
and '\t'. Is it expected behavior?
On Mon, Jun 13, 2016 at 12:10 AM, Jeff Jensen jeffjensen@users.sf.net
wrote:
Related
Bugs:
#389An expected value in mentioned test was wrong because it expects a valid XML char (174=0xAE) in encoded form.
I've fixed it too in 'xmlwriter' branch .
Another point is that method convertCharacterToEntity() encodes '\r', '\n' and '\t'. Is it expected behavior?
Thanks for reviewing and fixing. Please publish a new merge request.
Thanks, merged.
I'm not familiar with that code and I rarely have used this feature area. Does it work well this way and as you would expect using it or not?
Last edit: Jeff Jensen 2016-06-20