Hello, I have a problem when I unmarshal a XML. The CR (carriage return) and
LF (line feed) of the the string, dont show when I unmarshal. I check the
xml file, and the CR/LF are there, but dont show when I unmarshal. The
system out of the code is:

Douglas
Cavalcante (before unmarshal)
Douglas Cavalcante (after unmarshal)

######### THE CODE #########

String name = "Douglas\nCavalcante";            
System.out.println(name);

mapping.loadMapping("mappingpessoa.xml");
                        
Person p = new Person();
p.setName(name);
        
Writer w = new FileWriter("person.xml");
Marshaller m = new Marshaller(w);
m.setEncoding("ISO-8859-1");
m.setMapping(mapping);
m.marshal(p);                   
                                                
Reader r = new FileReader("person.xml");
Unmarshaller u = new Unmarshaller(Person.class);
u.setWhitespacePreserve(true);
u.setMapping(mapping);
        
Person p2 = (Person) u.unmarshal(r);
        
System.out.println(p2.getName());

######### THE MAPPING #########
<?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?>
<mapping>
   <class name="Person">
      <map-to xml="person" />
      <field name="name" type="java.lang.String" >
         <bind-xml name="name" node="attribute" />
      </field>
   </class>
</mapping>

######### THE CLASS #########
public class Person {
        
        private String name;

        public String getName() {
                return name;
        }

        public void setName(String name) {
                this.name = name;
        }
}


Thanks a lot for read this.

P.S.: sorry my poor english.
-- 
View this message in context: 
http://www.nabble.com/no-CR-LF-when-I-unmarshal-tp17625869p17625869.html
Sent from the Castor - User mailing list archive at Nabble.com.


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

    http://xircles.codehaus.org/manage_email


Reply via email to