Thanks for your reply, Marcelo the XML file that I marshal dont have the
"
" look:
<?xml version="1.0" encoding="ISO-8859-1"?>
<person name="Douglas
Cavalcante"/>
I update the castor to 1.2 and I still have the problem, any sugestion?
Marcelo Henrique wrote:
>
> Hi Douglas,
> I executed your code as follow and the castor preserved the \n see:
>
> [CODE]
>
> String name = "Douglas\nCavalcante";
> System.out.println( name );
> Mapping mapping = new Mapping();
> mapping.loadMapping( "C:/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() ); // I inserted
>
> [CODE]
>
> [OUTPUT]
>
> Douglas
> Cavalcante
> Douglas
> Cavalcante
>
> [OUTPUT]
>
> [XML]
>
> <?xml version="1.0" encoding="ISO-8859-1"?>
> <person name="Douglas
Cavalcante"/>
>
> [XML]
>
> I utilized castor 1.2 and Java 1.4 for this test.
>
> douglasmendonca <[EMAIL PROTECTED]> escreveu:
> 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 #########
>
>
>
>
>
>
>
>
>
>
> ######### 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
>
>
>
>
>
> *-----------------------------------------------------*
> || Marcelo Henrique De Oliveira Lima
> || Ciência da Computação - UECE
> || Linux User #399803
> || Slackware GNU/Linux Powered!
> *-----------------------------------------------------*
>
> ---------------------------------
> Abra sua conta no Yahoo! Mail, o único sem limite de espaço para
> armazenamento!
>
--
View this message in context:
http://www.nabble.com/no-CR-LF-when-I-unmarshal-tp17625869p17629645.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