users@jaxb.java.net

Re: JAXB escaping apostrophe (Single Quote)

From: Wolfgang Laun <wolfgang.laun_at_gmail.com>
Date: Tue, 6 Apr 2010 20:21:05 +0200

On Tue, Apr 6, 2010 at 4:57 PM, Ely Schoenfeld <ely.sun.1_at_mitalteli.com>
wrote:
> Wolfgang Laun escribió:
>>
>> On Tue, Apr 6, 2010 at 2:45 PM, Ely Schoenfeld <ely.sun.1_at_mitalteli.com>
>> wrote:
>
> Ok, "it doesn't have to" but should be possible. I'm not saying that every
> body have to use "& apos;", but it should be doable.
>

Whatever for? As Gary has shown, it's possible to represent any string value
as an attribute value by using one delimiter for quoting the string and the
corresponding entity within the string for representing occurrences of that
character as part of the string.

And if this string value happens to occur as element text, any reasonable
XML
serializer will represent quotes as " (and NOT &quot;) and apostrophes as '
(and NOT &apos;)

> I do consider possible to have some company that has an apostrophe in its
> name (i.e: [Somebody's Store]). Also could imagine some other company with
> double quotes in it's name (i.e: ["SomeInventedName" invetions store]). Or
> even both (i.e: [Sombody's "GREAT" inventions]).
>
> My point is that in this case at least, is not possible to stick to either
> one of these two attribute value delimiters. As I can see, you must use
> entities to generalize the "digital" invoice use.
>
> Am I right?
>

No - see Gary's mail.

The fact that *any* character *may *be represented in a number of ways does
not
establish an argument that this or that character *must *be represented in
some
specific way as long as it is valid XML. In fact, *any *character *can *be
represented
using a numeric entity, but if your encoding happens to be UTF-8, it is
*not necessary* to resort to this notation, and any serializer would be
sneered at
if it would use &#8364; (or the hexadecimal form) instead of € (the Euro
sign); or
use the corresponding form for any other codepoint greater 0x7F.

-W

> Ely.
>