Thanks, Jörg
My method now uses CompartWriter and works fine =)

public XStream getInstanceXStream(){
 XStream stream = new XStream(new XppDriver() {
             public HierarchicalStreamWriter createWriter(Writer out) {
                 return new CompactWriter(out) {
                     protected void writeText(QuickWriter writer, String
text) {
                         writer.write("<![CDATA[");
                         writer.write(text);
                         writer.write("]]>");
                     }
                 };
             }
         });
        return stream;
}


2012/1/23 Jörg Schaible <[email protected]>

> Hi Jairo,
>
> Jairo de Almeida wrote:
>
> > Hi group,
> >
> > Is possible ignore whitespace using xstream library
> >
> > For example: I have this xml
> >
> > <?xml version="1.0" encoding="ISO-8859-1"?><resultset>
> >         <inspecaofitossanitariaimport action="insert">
> >             <cdColetor><![CDATA[111]]></cdColetor>
> >            <dataAmostragem><![CDATA[19/01/2012]]></dataAmostragem>
> >            <id><![CDATA[33154434]]></id>
> >            <idUPNivel3><![CDATA[3808304280861701658]]></idUPNivel3>
> >           <rowVersion><![CDATA[1]]></rowVersion>
> >        </inspecaofitossanitariaimport>
> > </resultset>
> >
> >
> >
> > Using this converter source
> >
> > XStream stream = getInstanceXStream();
> > stream.processAnnotations(
> > new
> > Class[]
> {InspecaoFitossanitariaCollection.class,InspecaoFitossanitaria.class}
> > );
> > stream.setMode(XStream.NO_REFERENCES);
> > stream.autodetectAnnotations(true);
> > return stream.toXML(value);
> >
> > would be possible to generate an xml ignoring whitespaces from xml
> > identation
> >
> > For example getting this result:
> >
> > <?xml version="1.0" encoding="ISO-8859-1"?><resultset><
> > inspecaofitossanitariaimport action="insert"><cdColetor><![
> > CDATA[111]]></cdColetor><dataAmostragem><![CDA
> > TA[19/01/2012]]></dataAmostragem><id><!
> [CDATA[33154434]]></id><idUPNivel3><!
> > [CDATA[3808304280861701658]]></idUPNivel3><rowVersion><![CDATA[1]]></
> > rowVersion></inspecaofitossanitariaimport></resultset>
> >
> > Thanks, =)
>
> Simply use a CompartWriter instead of the PrettyPrintWriter that is
> normally
> used as default. You can either overwrite the drivers createWriter methods
> or use xstream's more basic "marshal" method instead of "toXML".
>
> Cheers,
> Jörg
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>    http://xircles.codehaus.org/manage_email
>
>
>


-- 
Sem mais...
Jairo de Almeida
email: [email protected]
msn: [email protected]

Reply via email to