I'm using JAXB 2.2.5 to output Xml from a JAXB Model, the data is populated from the database and occasionally the database contains non-displayable characters that it should not such as
0x1a
If it does then JAXB outputs invalid Xml by just outputting this char as is, shouldn't it escape it or something ?
Update
I wonder if there are any implementations that do fix this problem, maybe Eclipselink MOXy does ?
EDIT
I tried the workaround that fixes the illegal char issue however it changes the output in an undesirable way.
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><metadata created="2013-02-27T11:40:04.009Z" xmlns="http://musicbrainz.org/ns/mmd-2.0#" xmlns:ext="http://musicbrainz.org/ns/ext#-2.0"><cdstub-list count="1" offset="0"><cdstub id="w237dKURKperVfmckD5b_xo8BO8-" ext:score="100"><title>fred</title><artist></artist><track-list count="5"/></cdstub></cdstub-list></metadata>
to
<?xml version="1.0" ?><metadata xmlns:ext="http://musicbrainz.org/ns/ext#-2.0" xmlns="http://musicbrainz.org/ns/mmd-2.0#" created="2013-02-27T11:39:15.394Z"><cdstub-list count="1" offset="0"><cdstub id="w237dKURKperVfmckD5b_xo8BO8-" ext:score="100"><title>fred</title><artist></artist><track-list count="5"></track-list></cdstub></cdstub-list></metadata>
i.e <track-list count="5"/>
has become <track-list count="5"></track-list>
which is undesirable, I'm not sure why it is doing this.
It is apparently a common problem - and marked as a bug JAXB generates illegal XML characters.
You can find a workaround at Escape illegal characters
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With