Character reference "&#c" is an invalid XML character

C

cgbusch

"Character reference "&#c" is an invalid XML character"
With JDOM and Xerces in Java, I get the above error with sequences.
I need to be able to encode arbitrary char sequences in xml.

any suggestions?
 
R

Richard Tobin

cgbusch said:
"Character reference "&#c" is an invalid XML character"
With JDOM and Xerces in Java, I get the above error with sequences.

That's right. You can't put that character in an XML 1.0 document
even by using a character reference. (Why is there this restriction?
The usual answer is that XML is a text format, not a binary format.)
I need to be able to encode arbitrary char sequences in xml.

You'll have to really encode them, and translate them back again in
your application. If you just need to represent ascii characters
including controls, you could use some other Unicode characters
such as the private use characters (this would make translation
easy). Or you could encode everything using, say, base-64. Or
you could use an element to represent the illegal characters,
something like <char code="12"/>.

-- Richard
 
C

cgbusch

Bob Foster said:
base64, hex.

XML doesn't allow arbitrary characters.

Bob
I guess XML 1.1 allows all chars except ascii 0 because of lame C. So
for now I can just switch to that and hope that 1.2 will allow
MSXML allows all ASCII chars.
 
B

Bob Foster

cgbusch said:
"Bob Foster" <[email protected]> wrote in message
I guess XML 1.1 allows all chars except ascii 0 because of lame C. So
for now I can just switch to that and hope that 1.2 will allow
MSXML allows all ASCII chars.

Naw, you're just heading further down the wrong path. Encode the data to use
it within XML. There are no loopholes.

Bob
 
M

Mike Brown

Richard Tobin said:
You mean "because it would break existing APIs for negligible gain".


I think you will be disappointed.

So many people have this "what do I type to just make it work" attitude. I
don't even bother replying to them anymore. Let them crash & burn and cost
their company (or, these days, the company that outsourced to them) valuable
time & money as they scramble to fix these mistakes. Maybe then the hiring
managers will start to realize that perhaps not all people who put "XML" on
their resume are of equal proficiency. (Yes I know this rant won't help me
get a job in the field, but after 18 months of unemployment with no sign of
recovery unless I move to India, I'm understandably bitter).
FreeBSD rules!

Agreed.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,078
Latest member
MakersCBDBlood

Latest Threads

Top