Reputation: 3998
I am generating the xml by marshalling the xsd and I have xsl-fo to generate the pdf. I have a description field which has to be broken down to new lines.Something similar to what is in this thread Inserting a line break in a PDF generated from XSL FO using <xsl:value-of>
This is my code to marshall
JAXBContext context = JAXBContext.newInstance(List.class);
Marshaller m = context.createMarshaller();
m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
m.setProperty("com.sun.xml.bind.xmlDeclaration", Boolean.FALSE);
m.marshal(OrderList, stream);
StringWriter sw = new StringWriter();
m.marshal(OrderList, sw);
String val = sw.toString();
System.out.println(val);
When I marshall, generated xml doesn't retain 

instead it adds &#xA;
and the result is something like this
<description>REPAIR CAB DOOR&#xA;REPAIR &#xA;</description>
. If I don't have 

in the xml I can't create a line break in my pdf.
Upvotes: 2
Views: 5600
Reputation: 12817
Ok, I' guessing here (albeit somewhat educated). Whatever your input is to the generation of the <description>
element, it should not contain 

, but rather just '\n'
. I.e., instead of:
"This is a List:
List item 1
List item 2
List item 3
List item 4"
it shoudl be
"This is a List:\nList item 1\nList item 2\nList item 3\nList item 4"
Upvotes: 2