Disable attribute escapping

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Disable attribute escapping

Pedro Santos
Hello all,

I've been hitting my head on the wall because I want variables in my classes to be serialized as attributes. This I'm being able to do. The only problem is that some strings that express conditions (e.g. "i < 3") still get escaped even though it's not necessary.
Is there any way to turn off this behavior in XStream?

Thank you

--
Pedro Santos

"O que mais preocupa não é o grito dos violentos, dos corruptos, dos desonestos, dos sem ética. O que mais preocupa é o silêncio dos bons"

Martin Luther King

“Learning is experiencing. Everything else is just information.”

Albert Einstein

Reply | Threaded
Open this post in threaded view
|

Re: Disable attribute escapping

Jörg Schaible-4
Hi Perdo,

Pedro Santos wrote:

> Hello all,
>
> I've been hitting my head on the wall because I want variables in my
> classes to be serialized as attributes. This I'm being able to do. The
> only problem is that some strings that express conditions (e.g. "i < 3")
> still get escaped even though it's not necessary.

Why do you think that attribute values should *not* be escaped? XStream uses
by default either its own XML writer implementation or - in case of a StAX-
based driver - the StAX XMLOutputFactory. Even the latter escape attribute
values.

> Is there any way to turn off this behavior in XStream?

No by default, but you may overwrite PrettyPrintWriter.writeAttributeValue

- Jörg


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Disable attribute escapping

Pedro Santos
Hi Jorg,

I'm sorry, you are absolutely right. I was under the strange impression that attributes could contain valid XML characters without escaping. This was stupid.
I feel better now.

Thank you

On Thu, Sep 25, 2014 at 9:23 AM, Jörg Schaible <[hidden email]> wrote:
Hi Perdo,

Pedro Santos wrote:

> Hello all,
>
> I've been hitting my head on the wall because I want variables in my
> classes to be serialized as attributes. This I'm being able to do. The
> only problem is that some strings that express conditions (e.g. "i < 3")
> still get escaped even though it's not necessary.

Why do you think that attribute values should *not* be escaped? XStream uses
by default either its own XML writer implementation or - in case of a StAX-
based driver - the StAX XMLOutputFactory. Even the latter escape attribute
values.

> Is there any way to turn off this behavior in XStream?

No by default, but you may overwrite PrettyPrintWriter.writeAttributeValue

- Jörg


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email





--
Pedro Santos

"O que mais preocupa não é o grito dos violentos, dos corruptos, dos desonestos, dos sem ética. O que mais preocupa é o silêncio dos bons"

Martin Luther King

“Learning is experiencing. Everything else is just information.”

Albert Einstein