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-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


-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
dom4j-dev mailing list
dom4j-dev@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dom4j-dev

Reply via email to