-
Bug
-
Resolution: Won't Fix
-
P4
-
None
-
1.1.8, 1.2.2
-
generic, sparc
-
generic, solaris_2.5.1
Name: akC57697 Date: 02/02/99
The structure of the html document representing by the HTMLDocument has been
changed in JDK1.2.2. <P> tag has been added in the document structure.
Javadoc says:
"
A document that models html. The purpose of this model is to support both
browsing and editing. As a result, the structure
described by an html document is not exactly replicated by default.
The element structure that is modeled by default, is
built by the class HTMLDocument.HTMLReader, which implements
the HTMLEditorKit.ParserCallback protocol that the parser
expects. To change the structure one can subclass HTMLReader,
and reimplement the method getReader to return the new reader
implementation. The documentation for HTMLReader should be consulted
for the details of the default structure created. The
intent is that the document be non-lossy (although reproducing the html
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
format may result in a different format).
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
<-- P tag insertion is the essential change
The document models only html, and makes no attempt to store view
attributes in it. The elements are identified by the
StyleContext.NameAttribute attribute, which should always have a
value of type HTML.Tag that identifies the kind of
element. Some of the elements are (such as comments) are synthesized.
The HTMLFactory uses this attribute to determine what
kind of view to build.
This document supports incremental loading. The TokenThreshold property
controls how much of the parse is buffered before
trying to update the element structure of the document. This property is
set by the EditorKit so that subclasses can
disable it.
The Base property determines the URL against which relative URL's are
resolved against. By default, this will be the
Document.StreamDescriptionProperty if the value of the property is a URL.
If a <base> tag is encountered, the base will
become the URL specified by that tag. Because the base URL is a property,
it can of course be set directly.
The default content storage mechanism for this document is a gap buffer
(GapContent). Alternatives can be supplied by using
the constructor that takes a Content implementation.
"
The example:
-------------------------------------------------------
import javax.swing.text.html.*;
import javax.swing.text.*;
import java.io.*;
public class Test {
public static void main(String argv[]) {
String magic = "MAGIC_STRING1234567890";
String test =
"<!DOCTYPE HTML PUBLIC \"-//w3c//DTD "+
"html 3.2//EN\"><HTML><TITLE>Test</TITLE><BODY><VAR>"
+ magic + "</VAR></BODY></HTML>";
HTMLEditorKit c = new HTMLEditorKit(); // Create HTMLEditorKit object
HTMLDocument doc = null;
try {
doc = new HTMLDocument();
c.read(new StringReader(test), doc, 0);
System.out.println("The structure of the document is: ");
doc.dump(System.out);
} catch (Exception e) {
System.err.println("Unexpected " + e + " thrown");
}
}
}
-------------------------------------------------------
Output :
(###@###.###): java -fullversion
java full version "JDK-1.2.2-E"
(###@###.###): java Test > jdk1.2.2.txt
(###@###.###): jdk1.2
(###@###.###): java -fullversion
java full version "JDK-1.2-V"
(###@###.###): java Test > jdk1.2.txt
(###@###.###): diff jdk1.2.txt jdk1.2.2.txt
17d16
< name=title
18a18
> name=title
22d21
< name=head
23a23
> name=head
46a47,54
> <p <--P tag has been added
> name=p
> >
> <content
> name=content
> >
> [28,29][
> ]
======================================================================
- duplicates
-
JDK-4214849 HTMLEditorKit.read(...) generates redudancent paragraph element.
- Closed