TL;DR
JAXB should be replacing the Java \n
with 

which is the proper XML escaping. If you are not seeing this then there may be a bug in the version of the JAXB implementation you are using. For example this issue was fixed in EclipseLink JAXB (MOXy) in version 2.5.1:
Example
Java Model (Foo)
import javax.xml.bind.annotation.*;
@XmlRootElement
public class Foo {
private String bar;
@XmlAttribute
public String getBar() {
return bar;
}
public void setBar(String bar) {
this.bar = bar;
}
}
Demo Code
import javax.xml.bind.*;
public class Demo {
public static void main(String[] args) throws Exception {
JAXBContext jc = JAXBContext.newInstance(Foo.class);
Foo foo = new Foo();
foo.setBar("Hello\nWorld");
Marshaller marshaller = jc.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
marshaller.marshal(foo, System.out);
}
}
Output
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<foo bar="Hello
World"/>
Workaround
You can always use an XmlAdapter
to control any output in JAXB.