469,271 Members | 1,009 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,271 developers. It's quick & easy.

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

"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?

--
CB
Jul 20 '05 #1
6 11596
In article <f3**************************@posting.google.com >,
cgbusch <cg*****@yahoo.com> wrote:
"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

--
Spam filter: to mail me from a .com/.net site, put my surname in the headers.

FreeBSD rules!
Jul 20 '05 #2
base64, hex.

XML doesn't allow arbitrary characters.

Bob

"cgbusch" <cg*****@yahoo.com> wrote in message
news:f3**************************@posting.google.c om...
"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?

--
CB

Jul 20 '05 #3
"Bob Foster" <bo********@comcast.net> wrote in message news:<ONnRa.79705$ye4.59325@sccrnsc01>...
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.
Jul 20 '05 #4
"cgbusch" <cg*****@yahoo.com> schrieb im Newsbeitrag
news:f3**************************@posting.google.c om...
"Bob Foster" <bo********@comcast.net> wrote in message news:<ONnRa.79705$ye4.59325@sccrnsc01>...
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 �


XML 1.1 isn't finished yet.
MSXML allows all ASCII chars.


Not true. This bug has been fixed in MSXML3.

Jul 20 '05 #5
"cgbusch" <cg*****@yahoo.com> wrote in message
news:f3**************************@posting.google.c om...
"Bob Foster" <bo********@comcast.net> wrote in message

news:<ONnRa.79705$ye4.59325@sccrnsc01>...
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.


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

Bob
Jul 20 '05 #6
"Richard Tobin" <ri*****@cogsci.ed.ac.uk> wrote in message
news:bf***********@pc-news.cogsci.ed.ac.uk...
In article <f3**************************@posting.google.com >,
cgbusch <cg*****@yahoo.com> wrote:
I guess XML 1.1 allows all chars except ascii 0 because of lame C.
You mean "because it would break existing APIs for negligible gain".
So for now I can just switch to that and hope that 1.2 will allow �


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.
Jul 20 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Genzo | last post: by
12 posts views Thread by Robert Mark Bram | last post: by
8 posts views Thread by emailmygroup | last post: by
reply views Thread by Fredrik Lundh | last post: by
reply views Thread by bruce | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.