[jdom-interest] raw bytes turned into string and inserted into xml

Jeff Singer jeff.singer at vine.co.za
Mon Mar 18 06:47:13 PST 2002


Hi all,

I have a situation in which my applications input is a raw stream of
bytes, these bytes are actually ascii strings which occassionaly will
contain characters which are illegal to xml like 0x4, 0x0, 0x1 - quite a
few in this range. I use the string constructor which takes an encoding
to form them into java.lang.String objects. This works fine, I then
insert them as content onto a JDOM Element object and eventually after
building up my document I use an XMLOutputter to convert the DOM to an
XML string. This also works fine, where the problem lies is when the app
that accepts the xml string I have generated tries to parse the xml. It
throws JDOMException because the xml contains an invalid xml character
in xml's that were created from byte streams which contained characters
in the range already mentioned.


Sample App attached

Any help/ideas would be appreciated.

Thanks in advance
Jeff Singer
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Test.java
Type: application/x-javascript
Size: 863 bytes
Desc: not available
Url : http://jdom.org/pipermail/jdom-interest/attachments/20020318/98f01159/Test.js


More information about the jdom-interest mailing list