You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by George Zhang <ge...@itsp-inc.com> on 2006/02/24 19:02:07 UTC
FW: the extra whitespaces using xerces1.4.4
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:george@itsp-inc.com]
> Sent: February 24, 2006 12:08 PM
> To: 'webguy@theaimsgroup.com'
> 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
Re: FW: the extra whitespaces using xerces1.4.4
Posted by Michael Glavassevich <mr...@ca.ibm.com>.
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: mrglavas@ca.ibm.com
E-mail: mrglavas@apache.org
"George Zhang" <ge...@itsp-inc.com> 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:george@itsp-inc.com]
> Sent: February 24, 2006 12:08 PM
> To: 'webguy@theaimsgroup.com'
> 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: j-users-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-users-help@xerces.apache.org