users@jaxb.java.net

Re: Possible JAXB marshalling bug for XML 'character references'?

From: Kohsuke Kawaguchi <Kohsuke.Kawaguchi_at_Sun.COM>
Date: Mon, 30 Jul 2007 13:56:32 -0700

Wagle, Shriniwas wrote:
> Using JAXB, I'm creating an XML element and setting it's value using the
> "setValue (String value)" method.
>
> The value contains a combinations of some regular text characters
> intermixed with \u000d (CR) and \u000a (LF) characters.
>
> If I specify the value, for example, as a.setValue ("abc&#13;&#10;def"),
> when I marshall the XML, it replaces the & with &amp;. So the resultant
> output becomes "abc&amp#13;&amp#10;def". This makes the output entirely
> different from what it ought to be.
>
> To me this clearly seems to be incorrect behavior. I would have
> expected JAXB to marshall character references as is, without changing
> the & of a character reference to &amp;

I think you are mixing layers.

JAXB works above the XML infoset layer, and unicode character escape
like &#13; is below XML infoset layer. I think the current behavior is
the reasonable behavior.

-- 
Kohsuke Kawaguchi
Sun Microsystems                   kohsuke.kawaguchi_at_sun.com