Bugs item #1180791, was opened at 2005-04-11 15:01
Message generated for change (Comment added) made by tfromm
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=116035&aid=1180791&group_id=16035

Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Thomas Fromm (tfromm)
Assigned to: Maarten Coene (maartenc)
Summary: trimtext and newline problem in 1.5.x

Initial Comment:
In 1.4 modifyes the trimText(true) option for the OutputFormat 
not only the values between tags but inside the tags. 
 
e.g. source: <foo> bar </foo>  result: <foo>bar</foo> 
 
So i decided to set trimText(false). But i wanted to have newlines 
between the tags and so i used newlines(true). Everything fine. 
 
In 1.5.2 is the behaviour a littlebit different. trimText is still false 
and newlines is true but instead of: 
<foo> 
  <bar/> 
</foo> 
 
i get: 
<foo> 
 
  <bar/> 
 
</foo> 
 
Simply too much newlines. if i disable newlines, i get: 
<foo>  <bar/></foo> 
 
Ok, newline=true appends newlines after the tags without 
removing possible older existing newline tags. This would be not 
problem, if trimText=true never touches the value of tags, only 
removing whitespaces and similar stuff between tags. 
source: 
<Test>  <foo> bar </foo>  </Test> 
 
my expected result of trimtext: 
<Test><foo> bar </foo></Test> 
 
Of course dont change the current default behaviour, just add an 
option, that allows the user to decide, if he wants also the content 
of tags should be trimmed. 

----------------------------------------------------------------------

>Comment By: Thomas Fromm (tfromm)
Date: 2005-05-10 12:34

Message:
Logged In: YES 
user_id=79402

... always true of course ;) 

----------------------------------------------------------------------

Comment By: Thomas Fromm (tfromm)
Date: 2005-05-10 12:31

Message:
Logged In: YES 
user_id=79402

I checked out DOM4J_1_X_BRANCH and saw the changes made by you. 
But the result is the same as described. I used \n as line seperator. 
 
The error ist, that lastChar ist NUL (dez 0) in writePrintLn(...). So the 
condition is always false. 

----------------------------------------------------------------------

Comment By: Maarten Coene (maartenc)
Date: 2005-05-05 13:31

Message:
Logged In: YES 
user_id=178745

It should be fixed in CVS now, could you try again with the
latest sources from the DOM4J_1_X_BRANCH branch?

thanks
Maarten

----------------------------------------------------------------------

Comment By: Thomas Fromm (tfromm)
Date: 2005-04-26 15:10

Message:
Logged In: YES 
user_id=79402

Its possible, that you can fix trimText for 1.5.x in the same way as 
implemented in 1.6, because i'am not able to update to 1.6 (jaxen xpath 
problems and dom4j need stuff from the actual jaxen). 

----------------------------------------------------------------------

Comment By: Thomas Fromm (tfromm)
Date: 2005-04-21 06:51

Message:
Logged In: YES 
user_id=79402

 
 
 
            String xml="<?xml 
version=\1.0\?><root><foo>bar</foo></root>"; 
 
            SAXReader reader=new SAXReader(); 
            Document doc=reader.read(new StringReader(xml)); 
            // of with newlines 
            OutputFormat format = new OutputFormat(); 
            format.setNewlines(true); 
            // first time 
            StringWriter writer=new StringWriter(); 
            XMLWriter xmlwriter=new XMLWriter(writer, format); 
            xmlwriter.write(doc); 
            System.out.println(writer.toString()); 
 
            // 2nd time 
            doc=reader.read(new StringReader(writer.toString())); 
            writer=new StringWriter(); 
            xmlwriter=new XMLWriter(writer, format); 
            xmlwriter.write(doc); 
            System.out.println(writer.toString()); 

----------------------------------------------------------------------

Comment By: Maarten Coene (maartenc)
Date: 2005-04-20 19:05

Message:
Logged In: YES 
user_id=178745

Could you given me some example code I can execute that 
illustrates your problem?

thanks,
Maarten

----------------------------------------------------------------------

Comment By: Thomas Fromm (tfromm)
Date: 2005-04-13 09:34

Message:
Logged In: YES 
user_id=79402

Sorry, had wrong test results. It happens with writers and with streams. 
If i read pretty document and have not "trimtext" enabled at 
outputformat, then the result are too much new lines. 

----------------------------------------------------------------------

Comment By: Thomas Fromm (tfromm)
Date: 2005-04-13 09:28

Message:
Logged In: YES 
user_id=79402

It seems, that the multiple newlines at storing only happens, when i 
load a pretty printed document and store it into a outputstream. 
Using a Writer seems to work. 

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=116035&aid=1180791&group_id=16035


-------------------------------------------------------
This SF.Net email is sponsored by Oracle Space Sweepstakes
Want to be the first software developer in space?
Enter now for the Oracle Space Sweepstakes!
http://ads.osdn.com/?ad_id=7393&alloc_id=16281&op=click
_______________________________________________
dom4j-dev mailing list
dom4j-dev@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dom4j-dev

Reply via email to