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

javax.swing.text.Element.getName() does not work correctly

    XMLWordPrintable

    Details

    • Subcomponent:
    • CPU:
      sparc
    • OS:
      solaris_2.5.1

      Description



      Name: akC57697 Date: 01/05/99


      This bug was found by St.Petersburg Java SQE team (by Sergey Scherbakov).

       The method Element.getName() returns name of HTML tag in lowercase.

      The javadoc states:
        "public abstract interface Element

         Interface to describe a structural piece of a document.
         It is intended to capture the spirit of an SGML element."

        "public String getName()

           Fetches the name of the element. If the element is used to
           represent some type of structure, this would be the type name.
           Returns:
                the element name"

      HTML 4.0(and 3.2) specification says:
        "Element names are written in uppercase letters (e.g., BODY).
         Attribute names are written in lowercase letters (e.g., lang,
         onsubmit). Recall that in HTML, element and attribute names are
         case-insensitive; the convention is meant to encourage readability.
         (http://www.w3.org/TR/REC-html40/about.html#h-1.2.1)
        "

      The example:
      -------------------------------------------------------------
      import javax.swing.text.html.*;
      import javax.swing.text.*;
      import java.io.*;

      public class test {

          public static void main(String argv[]) {

              String[] checkedTag = {"H1","H2","H3","H4","H5","H6","P"};

              String magic="MAGIC_STRING";

              String prefix="<!DOCTYPE HTML PUBLIC \"-//w3c//DTD html
      3.2//EN\"><HTML><TITLE>Test</TITLE><BODY>";
              String suffix="</BODY></HTML>";
              String test;

              HTMLEditorKit c = null;
              HTMLDocument doc = null;
              Element e = null;

              for(int i=0; i<checkedTag.length; i++) {
                  c = null;
                  doc = null;

                  c = new HTMLEditorKit();
                  doc = new HTMLDocument();

                  test = prefix +
      "<"+checkedTag[i]+">"+magic+"</"+checkedTag[i]+">"+suffix;

                  try {
                      c.read(new StringReader(test),doc,0);
                  } catch (Exception e1) {
                      System.err.println( "Unexpected exception " + e1 );
                  }

                  e = doc.getDefaultRootElement().getElement(1).getElement(0);


                  System.err.println("Method getName() return: "+
                          e.getName()+" for tag: "+checkedTag[i]);
              }

          }

      }
      -------------------------------------------------------------

      Output:
      Method getName() return: h1 for tag: H1
      Method getName() return: h2 for tag: H2
      Method getName() return: h3 for tag: H3
      Method getName() return: h4 for tag: H4
      Method getName() return: h5 for tag: H5
      Method getName() return: h6 for tag: H6
      Method getName() return: p for tag: P

      ======================================================================

        Attachments

          Activity

            People

            Assignee:
            tprinzinsunw Timothy Prinzing (Inactive)
            Reporter:
            akuzminorcl Alexander Kuzmin (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: