Calling setIndent() [1] with a non-zero value will cause the serializer to 
pretty-print the document. It will add white space. If you don't want that 
don't call setIndent().

[1] 
http://xerces.apache.org/xerces2-j/javadocs/other/org/apache/xml/serialize/OutputFormat.html#setIndent(int)

Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: [EMAIL PROTECTED]
E-mail: [EMAIL PROTECTED]

"George Zhang" <[EMAIL PROTECTED]> wrote on 02/24/2006 01:02:07 PM:

> Hi Guys, 
> I am not sure whether or not the following issue is a BUG. Please 
> help me or give me some advice. 
> Thanks, 
> George 
> ______________________________________________ 
> From:   George Zhang [mailto:[EMAIL PROTECTED] 
> Sent:   February 24, 2006 12:08 PM 
> To:     '[EMAIL PROTECTED]' 
> Subject:        the extra whitespaces using xerces1.4.4 
> Importance:     High 
> Hi Guys, 
> I have an weird issue about the org.apache.xml.serialize package. 
> When I tried to transform the XML document into a string, I got the 
> extra whitespaces for the inputted value. The sample is as followed:
> the inputted string in the document: CMD, Test-Ann - exclude Test 
> BMK, CMD Recharge OK 
> after transformation, the return value was: CMD, Test -Ann - exclude 
Test 
>     BMK, CMD Recharge OK 
> In this case, I got the extra characters. It is so weird. I am using the 

> xerces1.4.4. Please give me some idea. 
> Here are the some snipcodes: 
>         OutputFormat format = new OutputFormat(doc);   //Serialize DOM 
>             format.setEncoding("ISO-8859-1"); 
>             format.setMethod("xml"); 
>             format.setIndent(2); 
>             StringWriter stringOut = new StringWriter();  //Writer 
> will be a String 
>             XMLSerializer serial = new XMLSerializer(stringOut, format); 

>             serial.asDOMSerializer(); // As a DOM Serializer 
>             serial.serialize(doc.getDocumentElement()); 
>         xmlResponse = stringOut.toString(); //Spit out DOM as a String 
> Thanks, 
> George 

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to