Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » JDOM User »

[jdom-interest] jdom 1.0 XMLOutputter

Bill Leng

2004-09-21


Hi,

I am trying jdom 1.0 and found that XMLOutputter now manipulates \n and
\r. This behaviour, I believe, is a bug because I can not get exactly
what I put in. The actual manipulation code is in
XMLOutputter.escapeElementEntities. It is added in jdom 1.0. Can anyone
shed some light on this? Please see the attached test file for detail.

--
Bill Leng
Sr. Software Engineer
Metatomix, Inc.
Tel: (901)261-8911
Fax: (901)261-8901

import org.jdom.*;
import org.jdom.output.*;
import java.io.*;

public class JdomTest
{
public static void main(String[] args)
{
  String s1 = "\n";
  Text t1 = new Text(s1);
  String s2 = "\r";
  Text t2 = new Text(s2);
  XMLOutputter o = new XMLOutputter();
  StringWriter w1 = new StringWriter();
  StringWriter w2 = new StringWriter();
  try
  {
   o.output(t1, w1);
   String ss1 = w1.toString();
   if(s1.equals(ss1))
   {
    System.out.println("Output 1: OK");
   }
   else
   {
    System.out.println("Output 1: wrong");
   }
   o.output(t2, w2);
   String ss2 = w2.toString();
   if(s2.equals(ss2))
   {
    System.out.println("Output 2: OK");
   }
   else
   {
    System.out.println("Output 2: wrong");
   }
  }
  catch (IOException e)
  {
   e.printStackTrace();
  }

}
}
_______________________________________________
To control your jdom-interest membership:
http://www.jdom.org/mailman/options/jdom-interest/youraddr@(protected)
©2008 junlu.com - Jax Systems, LLC, U.S.A.