Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4214848

HTMLEditorKit.read(...) creates Document for html with empty BODY.

XMLWordPrintable

    • beta
    • sparc
    • solaris_2.5.1



      Name: aaC67449 Date: 02/25/99


      HTMLEditorKit.read(...) creates incorrect Document for html with empty BODY.
      It generates two BODY sections.

      See example
      ------------------Example-----------------------------------
      import javax.swing.text.html.*;
      import javax.swing.text.html.*;
      import javax.swing.text.*;
      import java.io.*;
      public class Test {

         public static void main(String argv[]) {
          String test1="<!DOCTYPE HTML PUBLIC \"-//w3c//DTD html 3.2//EN\"><HTML><HEAD><TITLE>test</TITLE></HEAD><BODY></BODY></HTML>";
          HTMLEditorKit c= new HTMLEditorKit();
          Document doc = c.createDefaultDocument();
              
          try {
             c.read(new StringReader(test1),doc,0); // prepare test document
             StringWriter sw=new StringWriter();
             c.write(sw,doc,0,10);
             System.out.println(sw.toString());
             
             
          } catch(Exception e) {
              e.printStackTrace();
          }
         }

      }
      -------------------Output------------------------------------
      <html>
        <head>
        <title>test </title>
        </head>
        
       
        <body>
          
        </body>
        <body>
          <p>
            
          </p>
        </body>
      </html>
       
      ======================================================================

            svioletsunw Scott Violet (Inactive)
            alisunw Ali Ali (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: