You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by bu...@apache.org on 2003/06/18 13:42:32 UTC
DO NOT REPLY [Bug 20865] New: -
newlines '\n' appearing in strings not converted
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=20865>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND
INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=20865
newlines '\n' appearing in strings not converted
Summary: newlines '\n' appearing in strings not converted
Product: Commons
Version: unspecified
Platform: PC
OS/Version: Windows NT/2K
Status: NEW
Severity: Normal
Priority: Other
Component: Digester
AssignedTo: commons-dev@jakarta.apache.org
ReportedBy: marcus.keane@ft.com
Newline conversion of \n to single character does not happen as per Java
Properties files.
Digester version 1.5
Microsoft Windows 2000
5.00.2195
Service Pack 3
Java Version 1.4.1_01
Reproducable example of bug:
MyExample.java
==============
package demos.digesterbug;
import org.apache.commons.digester.Digester;
import org.xml.sax.SAXException;
import demos.MyTag;
import java.io.File;
import java.io.IOException;
public class MyExample {
public MyExample() {
digesterBugTest();
}
public static void main(String[] args) {
new MyExample();
}
private void digesterBugTest(){
Digester digester = new Digester();
digester.setValidating(false);
digester.addObjectCreate("root/tag", MyTag.class );
digester.addSetProperties("root/tag","attrib", "attrib" );
digester.addCallMethod("root/tag", "setBody", 0);
try {
MyTag abp = (MyTag) digester.parse(new File("digesterTest.xml"));
System.out.println("abp.getBody() = " + abp.getBody());
System.out.println("abp.getAttrib() = " + abp.getAttrib());
String verify = "Line one followed by two newlines.\n\nLine two
followed by two newlines.\n\nLast Line.";
System.out.println("Confirm a normal string works = " + verify);
} catch (IOException e) {
e.printStackTrace();
} catch (SAXException e) {
e.printStackTrace();
}
}
}
MyTag.java
==========
package demos.digesterbug;
public class MyTag {
private String attrib;
private String body;
public String getAttrib() {
return attrib;
}
public void setAttrib(String attrib) {
this.attrib = attrib;
}
public String getBody() {
return body;
}
public void setBody(String body) {
this.body = body;
}
}
digesterTest.xml
================
<?xml version="1.0" encoding="utf-8"?>
<root>
<tag attrib="Line one followed by two newlines.\n\nLine two followed by two
newlines.\n\nLast Line.">
Line one followed by two newlines.\n\nLine two followed by two newlines.\n\nLast
Line.
</tag>
</root>
Example of output
=================
abp.getBody() = Line one followed by two newlines.\n\nLine two followed by two
newlines.\n\nLast Line.
abp.getAttrib() = Line one followed by two newlines.\n\nLine two followed by two
newlines.\n\nLast Line.
Confirm a normal string works = Line one followed by two newlines.
Line two followed by two newlines.
Last Line.
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org