You are viewing a plain text version of this content. The canonical link for it is here.
Posted to general@xerces.apache.org by Greg Matthews <gm...@flex.com.au> on 2000/01/17 01:39:57 UTC

Serializers + white space

regarding the proposed/imminent feature...

parser.setFeature( "http://apache.org/xml/features/dom/include-ignorable-whitespace", true | false );

is there a workaround to this in the meantime?


i'm trying to "pretty print" a Document. if that Document was created by
reading the xml from a file then it appears almost the same as
entered in the file.

e.g.

if the file looks like this

<a>      <b>hello</b>  </a>

then i'd like it to print like this

<a>
    <b>hello</b>
</a>


i've played around with some of the settings in OutputFormat
but haven't been able to get the result i want.

any help much appreciated,
greg.

Re: Serializers + white space

Posted by Greg Matthews <gm...@flex.com.au>.
thanks for the response.

i'm using DOM.

not sure how to get the latest version from CVS.
i'm using the 1.0.1 java build available for download.

any estimates of when will the 
http://apache.org/xml/features/dom/include-ignorable-whitespace feature 
be available in a jar download?

thanks,
greg

----- Original Message ----- 
From: Assaf Arkin <ar...@exoffice.com>
To: <xe...@xml.apache.org>
Sent: Monday, January 17, 2000 1:02 PM
Subject: Re: Serializers + white space


> I understood that this feature is in the CVS.
> 
> OutputFormat is not going to help you. The Serializer cannot guess that
> the space is redundant and strip it. If you're using SAX parser -> SAX
> serializer the whitespace will show as ignorable and pretty printing
> will work correctly.
> 
> If you're using DOM parser -> DOM serializer, you'll need to use this
> feature or otherwise exterminate all the spaces from the DOM tree.
> 
> arkin
> 
> 
> > Greg Matthews wrote:
> > 
> > 
> > regarding the proposed/imminent feature...
> > 
> > parser.setFeature(
> > "http://apache.org/xml/features/dom/include-ignorable-whitespace", true
> > | false );
> > 
> > is there a workaround to this in the meantime?
> > 
> > 
> > i'm trying to "pretty print" a Document. if that Document was created
> > by
> > reading the xml from a file then it appears almost the same as
> > entered in the file.
> > 
> > e.g.
> > 
> > if the file looks like this
> > 
> > <a>      <b>hello</b>  </a>
> > 
> > then i'd like it to print like this
> > 
> > <a>
> >     <b>hello</b>
> > </a>
> > 
> > 
> > i've played around with some of the settings in OutputFormat
> > but haven't been able to get the result i want.
> > 
> > any help much appreciated,
> > greg.
> 


Re: Serializers + white space

Posted by Assaf Arkin <ar...@exoffice.com>.
I understood that this feature is in the CVS.

OutputFormat is not going to help you. The Serializer cannot guess that
the space is redundant and strip it. If you're using SAX parser -> SAX
serializer the whitespace will show as ignorable and pretty printing
will work correctly.

If you're using DOM parser -> DOM serializer, you'll need to use this
feature or otherwise exterminate all the spaces from the DOM tree.

arkin


> Greg Matthews wrote:
> 
> 
> regarding the proposed/imminent feature...
> 
> parser.setFeature(
> "http://apache.org/xml/features/dom/include-ignorable-whitespace", true
> | false );
> 
> is there a workaround to this in the meantime?
> 
> 
> i'm trying to "pretty print" a Document. if that Document was created
> by
> reading the xml from a file then it appears almost the same as
> entered in the file.
> 
> e.g.
> 
> if the file looks like this
> 
> <a>      <b>hello</b>  </a>
> 
> then i'd like it to print like this
> 
> <a>
>     <b>hello</b>
> </a>
> 
> 
> i've played around with some of the settings in OutputFormat
> but haven't been able to get the result i want.
> 
> any help much appreciated,
> greg.