2

I have a string with newlines in an attribute parameter :

<rule-parameter formattingMethod="NO_FORMATTING_METHOD" type="String" value="Hello,      
My name is luba.   
How are you?"/>

When I unmarshal this xml the object that I get for this property the string is in one line.

What should I do so the java property will also have newline in the string ?

bdoughan
  • 147,609
  • 23
  • 300
  • 400
LubaT
  • 129
  • 2
  • 9
  • Try to put the text in CDATA or maybe
    elements. Take a look on this thread: http://stackoverflow.com/questions/2986297/line-break-in-xml
    – Balint Bako Jun 20 '13 at 14:06

1 Answers1

3

An XML parser (including JAXB) will not preserve a newline in an XML attribute.

You will need to move this content to an XML element instead.

bdoughan
  • 147,609
  • 23
  • 300
  • 400
  • The linked section does not mention anything about not preserving newlines. It only specifies that multiple carriage return (+ line feed) characters are normalized to a single line feed character. – supik Aug 27 '18 at 14:16