[jdom-interest] Problem with XMLOutputter beta

stephan.segschneider at snellwilcox.com stephan.segschneider at snellwilcox.com
Fri Jul 6 01:01:28 PDT 2001


Hi Jason

If I could I would send you the application I wrote (it's a specialised GUI XML
editor) and with the settings I showed it works exactly as I described. Text
data is restricted to my 'Comment' elements, all the other elements only use
attributes. 

---------------------
    <Templates author="NN" version="0.0.1" >
        <Comment>You can use spaces and newlines in your comments.</Comment>
        <Tpl tplID="TPL_DEFAULT" label="TPL file" tplVersion="1" ratio="1.0">
            <Comment>Default for ratio is 1.0.</Comment>
            <Template dialogList="DLG_EMPTY" label="Product Template" >
                <Comment>Comment 1
Comment 2 in new line

Comment 3 in another line

    four spaces at the begining of the line.</Comment>
            </Template>
        </Tpl>
    </Templates>
----------------------

 Cheers,
               Stephan

 
____________________Reply Separator____________________
Subject:    Re: [jdom-interest] Problem with XMLOutputter beta
Author: "Jason Hunter" <jhunter at acm.org>
Date:       05/07/01 18:38

stephan.segschneider at snellwilcox.com wrote:
> 
> I have just converted my application back to JDOM beta 6. Using the following
> code does solve my problem completely. You can mess up the formatting of an
> existing XML file with any text editor (add spaces, add newlines, add tabs
> whatsoever) and after loading the XML via SaxBuilder and writing it via the
code
> shown below you will get everything repaired - formatted the way you expect it
-
> indentation four spaces, no additional empty lines between elements AND all
the
> text data *untouched*!
> 
>         fileWriter = new FileWriter(location);
>         XMLOutputter outputter = new XMLOutputter("    ", true);
>         outputter.setTrimText(false);
>         outputter.setExpandEmptyElements(false);
>         outputter.output(doc, fileWriter);

Pretty formatting is done by adding and removing text whitespace -- so I
don't see how you can say everything's formatted nicely and text data is
untouched.  Some text nodes are definitely being touched.  Given the
flags above you're adding whitespace without ever removing any, so a
pretty printed document read in and output this way will be whitespace
padded even tho it's not necessary.

-jh-
_______________________________________________
To control your jdom-interest membership:
http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhost.co
m




----------------------------------------------------------------------
The contents of this communication are confidential to the normal user of
the email address to which it was sent.  If you have received this email
in error, any use, dissemination, forwarding, printing or copying of this
email is strictly prohibited.  If this is the case, please notify the sender
and delete this message.
----------------------------------------------------------------------




More information about the jdom-interest mailing list