Problem with marshalling/unmarshalling of long texts with newlines inside

View: New views
3 Messages — Rating Filter:   Alert me  

Problem with marshalling/unmarshalling of long texts with newlines inside

by pinolino :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

i have an object and marshal it into xml. The result than looks something like the following:

<?xml version="1.0" encoding="UTF-8"?>
<myobject>
  <mykey>TEXT1</mykey>
  <text>This is my text.
My text has newlines inside.
All newlines are correctly in XML like in the object-text before.
  </text>
</myobject>

But if i now want to unmarshal this xml, all the newlines inside the tags <text></text> are getting lost!
But i need the text like it was before with newlines.

So i hope, someone can help me. I dont know what i'm doing wrong.
Thanks.

Re: Problem with marshalling/unmarshalling of long texts with newlines inside

by Werner Guttmann :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Adding an xml:space="preserve" to your XML should help. Castor does,
indeed, respect that instruction to preserve whitespace.

Regards
Werner

pinolino wrote:

> Hi,
>
> i have an object and marshal it into xml. The result than looks something
> like the following:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <myobject>
>   <mykey>TEXT1</mykey>
>   <text>This is my text.
> My text has newlines inside.
> All newlines are correctly in XML like in the object-text before.
>   </text>
> </myobject>
>
> But if i now want to unmarshal this xml, all the newlines inside the tags
> <text></text> are getting lost!
> But i need the text like it was before with newlines.
>
> So i hope, someone can help me. I dont know what i'm doing wrong.
> Thanks.

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

    http://xircles.codehaus.org/manage_email



Re: Problem with marshalling/unmarshalling of long texts with newlines inside

by pinolino :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Yes, thats it. Thanks, now it works fine.

Werner Guttmann wrote:
Adding an xml:space="preserve" to your XML should help. Castor does,
indeed, respect that instruction to preserve whitespace.

Regards
Werner

pinolino wrote:
> Hi,
>
> i have an object and marshal it into xml. The result than looks something
> like the following:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <myobject>
>   <mykey>TEXT1</mykey>
>   <text>This is my text.
> My text has newlines inside.
> All newlines are correctly in XML like in the object-text before.
>   </text>
> </myobject>
>
> But if i now want to unmarshal this xml, all the newlines inside the tags
> <text></text> are getting lost!
> But i need the text like it was before with newlines.
>
> So i hope, someone can help me. I dont know what i'm doing wrong.
> Thanks.

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

    http://xircles.codehaus.org/manage_email

LightInTheBox - Buy quality products at wholesale price