jaxp/src/com/sun/org/apache/xml/internal/serialize/HTMLdtd.java
author joehw
Tue, 29 Jul 2014 20:52:36 -0700
changeset 25834 aba3efbf4ec5
parent 12457 c348e06f0e82
permissions -rw-r--r--
8035467: Xerces Update: Move to Xalan based DOM L3 serializer. Deprecate Xerces' native serializer. Reviewed-by: lancea
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6
7f561c08de6b Initial load
duke
parents:
diff changeset
     1
/*
7f561c08de6b Initial load
duke
parents:
diff changeset
     2
 * reserved comment block
7f561c08de6b Initial load
duke
parents:
diff changeset
     3
 * DO NOT REMOVE OR ALTER!
7f561c08de6b Initial load
duke
parents:
diff changeset
     4
 */
7f561c08de6b Initial load
duke
parents:
diff changeset
     5
/*
25834
aba3efbf4ec5 8035467: Xerces Update: Move to Xalan based DOM L3 serializer. Deprecate Xerces' native serializer.
joehw
parents: 12457
diff changeset
     6
 * Licensed to the Apache Software Foundation (ASF) under one or more
aba3efbf4ec5 8035467: Xerces Update: Move to Xalan based DOM L3 serializer. Deprecate Xerces' native serializer.
joehw
parents: 12457
diff changeset
     7
 * contributor license agreements.  See the NOTICE file distributed with
aba3efbf4ec5 8035467: Xerces Update: Move to Xalan based DOM L3 serializer. Deprecate Xerces' native serializer.
joehw
parents: 12457
diff changeset
     8
 * this work for additional information regarding copyright ownership.
aba3efbf4ec5 8035467: Xerces Update: Move to Xalan based DOM L3 serializer. Deprecate Xerces' native serializer.
joehw
parents: 12457
diff changeset
     9
 * The ASF licenses this file to You under the Apache License, Version 2.0
aba3efbf4ec5 8035467: Xerces Update: Move to Xalan based DOM L3 serializer. Deprecate Xerces' native serializer.
joehw
parents: 12457
diff changeset
    10
 * (the "License"); you may not use this file except in compliance with
aba3efbf4ec5 8035467: Xerces Update: Move to Xalan based DOM L3 serializer. Deprecate Xerces' native serializer.
joehw
parents: 12457
diff changeset
    11
 * the License.  You may obtain a copy of the License at
6
7f561c08de6b Initial load
duke
parents:
diff changeset
    12
 *
7f561c08de6b Initial load
duke
parents:
diff changeset
    13
 *      http://www.apache.org/licenses/LICENSE-2.0
7f561c08de6b Initial load
duke
parents:
diff changeset
    14
 *
7f561c08de6b Initial load
duke
parents:
diff changeset
    15
 * Unless required by applicable law or agreed to in writing, software
7f561c08de6b Initial load
duke
parents:
diff changeset
    16
 * distributed under the License is distributed on an "AS IS" BASIS,
7f561c08de6b Initial load
duke
parents:
diff changeset
    17
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
7f561c08de6b Initial load
duke
parents:
diff changeset
    18
 * See the License for the specific language governing permissions and
7f561c08de6b Initial load
duke
parents:
diff changeset
    19
 * limitations under the License.
7f561c08de6b Initial load
duke
parents:
diff changeset
    20
 */
7f561c08de6b Initial load
duke
parents:
diff changeset
    21
7f561c08de6b Initial load
duke
parents:
diff changeset
    22
7f561c08de6b Initial load
duke
parents:
diff changeset
    23
// Aug 21, 2000:
7f561c08de6b Initial load
duke
parents:
diff changeset
    24
//   Fixed bug in isElement and made HTMLdtd public.
7f561c08de6b Initial load
duke
parents:
diff changeset
    25
//   Contributed by Eric SCHAEFFER" <eschaeffer@posterconseil.com>
7f561c08de6b Initial load
duke
parents:
diff changeset
    26
7f561c08de6b Initial load
duke
parents:
diff changeset
    27
7f561c08de6b Initial load
duke
parents:
diff changeset
    28
package com.sun.org.apache.xml.internal.serialize;
7f561c08de6b Initial load
duke
parents:
diff changeset
    29
7f561c08de6b Initial load
duke
parents:
diff changeset
    30
import com.sun.org.apache.xerces.internal.dom.DOMMessageFormatter;
7f561c08de6b Initial load
duke
parents:
diff changeset
    31
7f561c08de6b Initial load
duke
parents:
diff changeset
    32
import java.io.InputStream;
7f561c08de6b Initial load
duke
parents:
diff changeset
    33
import java.io.InputStreamReader;
7f561c08de6b Initial load
duke
parents:
diff changeset
    34
import java.io.BufferedReader;
7f561c08de6b Initial load
duke
parents:
diff changeset
    35
import java.util.Hashtable;
7f561c08de6b Initial load
duke
parents:
diff changeset
    36
import java.util.Locale;
7f561c08de6b Initial load
duke
parents:
diff changeset
    37
7f561c08de6b Initial load
duke
parents:
diff changeset
    38
7f561c08de6b Initial load
duke
parents:
diff changeset
    39
/**
7f561c08de6b Initial load
duke
parents:
diff changeset
    40
 * Utility class for accessing information specific to HTML documents.
7f561c08de6b Initial load
duke
parents:
diff changeset
    41
 * The HTML DTD is expressed as three utility function groups. Two methods
7f561c08de6b Initial load
duke
parents:
diff changeset
    42
 * allow for checking whether an element requires an open tag on printing
7f561c08de6b Initial load
duke
parents:
diff changeset
    43
 * ({@link #isEmptyTag}) or on parsing ({@link #isOptionalClosing}).
7f561c08de6b Initial load
duke
parents:
diff changeset
    44
 * <P>
7f561c08de6b Initial load
duke
parents:
diff changeset
    45
 * Two other methods translate character references from name to value and
7f561c08de6b Initial load
duke
parents:
diff changeset
    46
 * from value to name. A small entities resource is loaded into memory the
7f561c08de6b Initial load
duke
parents:
diff changeset
    47
 * first time any of these methods is called for fast and efficient access.
7f561c08de6b Initial load
duke
parents:
diff changeset
    48
 *
25834
aba3efbf4ec5 8035467: Xerces Update: Move to Xalan based DOM L3 serializer. Deprecate Xerces' native serializer.
joehw
parents: 12457
diff changeset
    49
 * @author <a href="mailto:arkin@intalio.com">Assaf Arkin</a>
6
7f561c08de6b Initial load
duke
parents:
diff changeset
    50
 *
25834
aba3efbf4ec5 8035467: Xerces Update: Move to Xalan based DOM L3 serializer. Deprecate Xerces' native serializer.
joehw
parents: 12457
diff changeset
    51
 * @deprecated As of JDK 1.9, Xerces 2.9.0, Xerces DOM L3 Serializer implementation
aba3efbf4ec5 8035467: Xerces Update: Move to Xalan based DOM L3 serializer. Deprecate Xerces' native serializer.
joehw
parents: 12457
diff changeset
    52
 * is replaced by that of Xalan. Main class
aba3efbf4ec5 8035467: Xerces Update: Move to Xalan based DOM L3 serializer. Deprecate Xerces' native serializer.
joehw
parents: 12457
diff changeset
    53
 * {@link com.sun.org.apache.xml.internal.serialize.DOMSerializerImpl} is replaced
aba3efbf4ec5 8035467: Xerces Update: Move to Xalan based DOM L3 serializer. Deprecate Xerces' native serializer.
joehw
parents: 12457
diff changeset
    54
 * by {@link com.sun.org.apache.xml.internal.serializer.dom3.LSSerializerImpl}.
6
7f561c08de6b Initial load
duke
parents:
diff changeset
    55
 */
7f561c08de6b Initial load
duke
parents:
diff changeset
    56
public final class HTMLdtd
7f561c08de6b Initial load
duke
parents:
diff changeset
    57
{
7f561c08de6b Initial load
duke
parents:
diff changeset
    58
7f561c08de6b Initial load
duke
parents:
diff changeset
    59
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
    60
     * Public identifier for HTML 4.01 (Strict) document type.
7f561c08de6b Initial load
duke
parents:
diff changeset
    61
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
    62
    public static final String HTMLPublicId = "-//W3C//DTD HTML 4.01//EN";
7f561c08de6b Initial load
duke
parents:
diff changeset
    63
7f561c08de6b Initial load
duke
parents:
diff changeset
    64
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
    65
     * System identifier for HTML 4.01 (Strict) document type.
7f561c08de6b Initial load
duke
parents:
diff changeset
    66
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
    67
    public static final String HTMLSystemId =
7f561c08de6b Initial load
duke
parents:
diff changeset
    68
        "http://www.w3.org/TR/html4/strict.dtd";
7f561c08de6b Initial load
duke
parents:
diff changeset
    69
7f561c08de6b Initial load
duke
parents:
diff changeset
    70
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
    71
     * Public identifier for XHTML 1.0 (Strict) document type.
7f561c08de6b Initial load
duke
parents:
diff changeset
    72
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
    73
    public static final String XHTMLPublicId =
7f561c08de6b Initial load
duke
parents:
diff changeset
    74
        "-//W3C//DTD XHTML 1.0 Strict//EN";
7f561c08de6b Initial load
duke
parents:
diff changeset
    75
7f561c08de6b Initial load
duke
parents:
diff changeset
    76
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
    77
     * System identifier for XHTML 1.0 (Strict) document type.
7f561c08de6b Initial load
duke
parents:
diff changeset
    78
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
    79
    public static final String XHTMLSystemId =
7f561c08de6b Initial load
duke
parents:
diff changeset
    80
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";
7f561c08de6b Initial load
duke
parents:
diff changeset
    81
7f561c08de6b Initial load
duke
parents:
diff changeset
    82
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
    83
     * Table of reverse character reference mapping. Character codes are held
7f561c08de6b Initial load
duke
parents:
diff changeset
    84
     * as single-character strings, mapped to their reference name.
7f561c08de6b Initial load
duke
parents:
diff changeset
    85
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
    86
    private static Hashtable        _byChar;
7f561c08de6b Initial load
duke
parents:
diff changeset
    87
7f561c08de6b Initial load
duke
parents:
diff changeset
    88
7f561c08de6b Initial load
duke
parents:
diff changeset
    89
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
    90
     * Table of entity name to value mapping. Entities are held as strings,
7f561c08de6b Initial load
duke
parents:
diff changeset
    91
     * character references as <TT>Character</TT> objects.
7f561c08de6b Initial load
duke
parents:
diff changeset
    92
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
    93
    private static Hashtable        _byName;
7f561c08de6b Initial load
duke
parents:
diff changeset
    94
7f561c08de6b Initial load
duke
parents:
diff changeset
    95
7f561c08de6b Initial load
duke
parents:
diff changeset
    96
    private static Hashtable        _boolAttrs;
7f561c08de6b Initial load
duke
parents:
diff changeset
    97
7f561c08de6b Initial load
duke
parents:
diff changeset
    98
7f561c08de6b Initial load
duke
parents:
diff changeset
    99
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   100
     * Holds element definitions.
7f561c08de6b Initial load
duke
parents:
diff changeset
   101
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   102
    private static Hashtable        _elemDefs;
7f561c08de6b Initial load
duke
parents:
diff changeset
   103
7f561c08de6b Initial load
duke
parents:
diff changeset
   104
7f561c08de6b Initial load
duke
parents:
diff changeset
   105
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   106
     * Locates the HTML entities file that is loaded upon initialization.
7f561c08de6b Initial load
duke
parents:
diff changeset
   107
     * This file is a resource loaded with the default class loader.
7f561c08de6b Initial load
duke
parents:
diff changeset
   108
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   109
    private static final String     ENTITIES_RESOURCE = "HTMLEntities.res";
7f561c08de6b Initial load
duke
parents:
diff changeset
   110
7f561c08de6b Initial load
duke
parents:
diff changeset
   111
7f561c08de6b Initial load
duke
parents:
diff changeset
   112
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   113
     * Only opening tag should be printed.
7f561c08de6b Initial load
duke
parents:
diff changeset
   114
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   115
    private static final int ONLY_OPENING = 0x0001;
7f561c08de6b Initial load
duke
parents:
diff changeset
   116
7f561c08de6b Initial load
duke
parents:
diff changeset
   117
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   118
     * Element contains element content only.
7f561c08de6b Initial load
duke
parents:
diff changeset
   119
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   120
    private static final int ELEM_CONTENT = 0x0002;
7f561c08de6b Initial load
duke
parents:
diff changeset
   121
7f561c08de6b Initial load
duke
parents:
diff changeset
   122
7f561c08de6b Initial load
duke
parents:
diff changeset
   123
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   124
     * Element preserve spaces.
7f561c08de6b Initial load
duke
parents:
diff changeset
   125
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   126
    private static final int PRESERVE     = 0x0004;
7f561c08de6b Initial load
duke
parents:
diff changeset
   127
7f561c08de6b Initial load
duke
parents:
diff changeset
   128
7f561c08de6b Initial load
duke
parents:
diff changeset
   129
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   130
     * Optional closing tag.
7f561c08de6b Initial load
duke
parents:
diff changeset
   131
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   132
    private static final int OPT_CLOSING  = 0x0008;
7f561c08de6b Initial load
duke
parents:
diff changeset
   133
7f561c08de6b Initial load
duke
parents:
diff changeset
   134
7f561c08de6b Initial load
duke
parents:
diff changeset
   135
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   136
     * Element is empty (also means only opening tag)
7f561c08de6b Initial load
duke
parents:
diff changeset
   137
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   138
    private static final int EMPTY        = 0x0010 | ONLY_OPENING;
7f561c08de6b Initial load
duke
parents:
diff changeset
   139
7f561c08de6b Initial load
duke
parents:
diff changeset
   140
7f561c08de6b Initial load
duke
parents:
diff changeset
   141
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   142
     * Allowed to appear in head.
7f561c08de6b Initial load
duke
parents:
diff changeset
   143
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   144
    private static final int ALLOWED_HEAD = 0x0020;
7f561c08de6b Initial load
duke
parents:
diff changeset
   145
7f561c08de6b Initial load
duke
parents:
diff changeset
   146
7f561c08de6b Initial load
duke
parents:
diff changeset
   147
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   148
     * When opened, closes P.
7f561c08de6b Initial load
duke
parents:
diff changeset
   149
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   150
    private static final int CLOSE_P      = 0x0040;
7f561c08de6b Initial load
duke
parents:
diff changeset
   151
7f561c08de6b Initial load
duke
parents:
diff changeset
   152
7f561c08de6b Initial load
duke
parents:
diff changeset
   153
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   154
     * When opened, closes DD or DT.
7f561c08de6b Initial load
duke
parents:
diff changeset
   155
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   156
    private static final int CLOSE_DD_DT  = 0x0080;
7f561c08de6b Initial load
duke
parents:
diff changeset
   157
7f561c08de6b Initial load
duke
parents:
diff changeset
   158
7f561c08de6b Initial load
duke
parents:
diff changeset
   159
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   160
     * When opened, closes itself.
7f561c08de6b Initial load
duke
parents:
diff changeset
   161
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   162
    private static final int CLOSE_SELF   = 0x0100;
7f561c08de6b Initial load
duke
parents:
diff changeset
   163
7f561c08de6b Initial load
duke
parents:
diff changeset
   164
7f561c08de6b Initial load
duke
parents:
diff changeset
   165
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   166
     * When opened, closes another table section.
7f561c08de6b Initial load
duke
parents:
diff changeset
   167
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   168
    private static final int CLOSE_TABLE  = 0x0200;
7f561c08de6b Initial load
duke
parents:
diff changeset
   169
7f561c08de6b Initial load
duke
parents:
diff changeset
   170
7f561c08de6b Initial load
duke
parents:
diff changeset
   171
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   172
     * When opened, closes TH or TD.
7f561c08de6b Initial load
duke
parents:
diff changeset
   173
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   174
    private static final int CLOSE_TH_TD  = 0x04000;
7f561c08de6b Initial load
duke
parents:
diff changeset
   175
7f561c08de6b Initial load
duke
parents:
diff changeset
   176
7f561c08de6b Initial load
duke
parents:
diff changeset
   177
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   178
     * Returns true if element is declared to be empty. HTML elements are
7f561c08de6b Initial load
duke
parents:
diff changeset
   179
     * defines as empty in the DTD, not by the document syntax.
7f561c08de6b Initial load
duke
parents:
diff changeset
   180
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   181
     * @param tagName The element tag name (upper case)
7f561c08de6b Initial load
duke
parents:
diff changeset
   182
     * @return True if element is empty
7f561c08de6b Initial load
duke
parents:
diff changeset
   183
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   184
    public static boolean isEmptyTag( String tagName )
7f561c08de6b Initial load
duke
parents:
diff changeset
   185
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
   186
        return isElement( tagName, EMPTY );
7f561c08de6b Initial load
duke
parents:
diff changeset
   187
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   188
7f561c08de6b Initial load
duke
parents:
diff changeset
   189
7f561c08de6b Initial load
duke
parents:
diff changeset
   190
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   191
     * Returns true if element is declared to have element content.
7f561c08de6b Initial load
duke
parents:
diff changeset
   192
     * Whitespaces appearing inside element content will be ignored,
7f561c08de6b Initial load
duke
parents:
diff changeset
   193
     * other text will simply report an error.
7f561c08de6b Initial load
duke
parents:
diff changeset
   194
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   195
     * @param tagName The element tag name (upper case)
7f561c08de6b Initial load
duke
parents:
diff changeset
   196
     * @return True if element content
7f561c08de6b Initial load
duke
parents:
diff changeset
   197
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   198
    public static boolean isElementContent( String tagName )
7f561c08de6b Initial load
duke
parents:
diff changeset
   199
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
   200
        return isElement( tagName, ELEM_CONTENT );
7f561c08de6b Initial load
duke
parents:
diff changeset
   201
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   202
7f561c08de6b Initial load
duke
parents:
diff changeset
   203
7f561c08de6b Initial load
duke
parents:
diff changeset
   204
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   205
     * Returns true if element's textual contents preserves spaces.
7f561c08de6b Initial load
duke
parents:
diff changeset
   206
     * This only applies to PRE and TEXTAREA, all other HTML elements
7f561c08de6b Initial load
duke
parents:
diff changeset
   207
     * do not preserve space.
7f561c08de6b Initial load
duke
parents:
diff changeset
   208
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   209
     * @param tagName The element tag name (upper case)
7f561c08de6b Initial load
duke
parents:
diff changeset
   210
     * @return True if element's text content preserves spaces
7f561c08de6b Initial load
duke
parents:
diff changeset
   211
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   212
    public static boolean isPreserveSpace( String tagName )
7f561c08de6b Initial load
duke
parents:
diff changeset
   213
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
   214
        return isElement( tagName, PRESERVE );
7f561c08de6b Initial load
duke
parents:
diff changeset
   215
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   216
7f561c08de6b Initial load
duke
parents:
diff changeset
   217
7f561c08de6b Initial load
duke
parents:
diff changeset
   218
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   219
     * Returns true if element's closing tag is optional and need not
7f561c08de6b Initial load
duke
parents:
diff changeset
   220
     * exist. An error will not be reported for such elements if they
7f561c08de6b Initial load
duke
parents:
diff changeset
   221
     * are not closed. For example, <tt>LI</tt> is most often not closed.
7f561c08de6b Initial load
duke
parents:
diff changeset
   222
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   223
     * @param tagName The element tag name (upper case)
7f561c08de6b Initial load
duke
parents:
diff changeset
   224
     * @return True if closing tag implied
7f561c08de6b Initial load
duke
parents:
diff changeset
   225
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   226
    public static boolean isOptionalClosing( String tagName )
7f561c08de6b Initial load
duke
parents:
diff changeset
   227
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
   228
        return isElement( tagName, OPT_CLOSING );
7f561c08de6b Initial load
duke
parents:
diff changeset
   229
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   230
7f561c08de6b Initial load
duke
parents:
diff changeset
   231
7f561c08de6b Initial load
duke
parents:
diff changeset
   232
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   233
     * Returns true if element's closing tag is generally not printed.
7f561c08de6b Initial load
duke
parents:
diff changeset
   234
     * For example, <tt>LI</tt> should not print the closing tag.
7f561c08de6b Initial load
duke
parents:
diff changeset
   235
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   236
     * @param tagName The element tag name (upper case)
7f561c08de6b Initial load
duke
parents:
diff changeset
   237
     * @return True if only opening tag should be printed
7f561c08de6b Initial load
duke
parents:
diff changeset
   238
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   239
    public static boolean isOnlyOpening( String tagName )
7f561c08de6b Initial load
duke
parents:
diff changeset
   240
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
   241
        return isElement( tagName, ONLY_OPENING );
7f561c08de6b Initial load
duke
parents:
diff changeset
   242
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   243
7f561c08de6b Initial load
duke
parents:
diff changeset
   244
7f561c08de6b Initial load
duke
parents:
diff changeset
   245
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   246
     * Returns true if the opening of one element (<tt>tagName</tt>) implies
7f561c08de6b Initial load
duke
parents:
diff changeset
   247
     * the closing of another open element (<tt>openTag</tt>). For example,
7f561c08de6b Initial load
duke
parents:
diff changeset
   248
     * every opening <tt>LI</tt> will close the previously open <tt>LI</tt>,
7f561c08de6b Initial load
duke
parents:
diff changeset
   249
     * and every opening <tt>BODY</tt> will close the previously open <tt>HEAD</tt>.
7f561c08de6b Initial load
duke
parents:
diff changeset
   250
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   251
     * @param tagName The newly opened element
7f561c08de6b Initial load
duke
parents:
diff changeset
   252
     * @param openTag The already opened element
7f561c08de6b Initial load
duke
parents:
diff changeset
   253
     * @return True if closing tag closes opening tag
7f561c08de6b Initial load
duke
parents:
diff changeset
   254
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   255
    public static boolean isClosing( String tagName, String openTag )
7f561c08de6b Initial load
duke
parents:
diff changeset
   256
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
   257
        // Several elements are defined as closing the HEAD
7f561c08de6b Initial load
duke
parents:
diff changeset
   258
        if ( openTag.equalsIgnoreCase( "HEAD" ) )
7f561c08de6b Initial load
duke
parents:
diff changeset
   259
            return ! isElement( tagName, ALLOWED_HEAD );
7f561c08de6b Initial load
duke
parents:
diff changeset
   260
        // P closes iteself
7f561c08de6b Initial load
duke
parents:
diff changeset
   261
        if ( openTag.equalsIgnoreCase( "P" ) )
7f561c08de6b Initial load
duke
parents:
diff changeset
   262
            return isElement( tagName, CLOSE_P );
7f561c08de6b Initial load
duke
parents:
diff changeset
   263
        // DT closes DD, DD closes DT
7f561c08de6b Initial load
duke
parents:
diff changeset
   264
        if ( openTag.equalsIgnoreCase( "DT" ) || openTag.equalsIgnoreCase( "DD" ) )
7f561c08de6b Initial load
duke
parents:
diff changeset
   265
            return isElement( tagName, CLOSE_DD_DT );
7f561c08de6b Initial load
duke
parents:
diff changeset
   266
        // LI and OPTION close themselves
7f561c08de6b Initial load
duke
parents:
diff changeset
   267
        if ( openTag.equalsIgnoreCase( "LI" ) || openTag.equalsIgnoreCase( "OPTION" ) )
7f561c08de6b Initial load
duke
parents:
diff changeset
   268
            return isElement( tagName, CLOSE_SELF );
7f561c08de6b Initial load
duke
parents:
diff changeset
   269
        // Each of these table sections closes all the others
7f561c08de6b Initial load
duke
parents:
diff changeset
   270
        if ( openTag.equalsIgnoreCase( "THEAD" ) || openTag.equalsIgnoreCase( "TFOOT" ) ||
7f561c08de6b Initial load
duke
parents:
diff changeset
   271
             openTag.equalsIgnoreCase( "TBODY" ) || openTag.equalsIgnoreCase( "TR" ) ||
7f561c08de6b Initial load
duke
parents:
diff changeset
   272
             openTag.equalsIgnoreCase( "COLGROUP" ) )
7f561c08de6b Initial load
duke
parents:
diff changeset
   273
            return isElement( tagName, CLOSE_TABLE );
7f561c08de6b Initial load
duke
parents:
diff changeset
   274
        // TD closes TH and TH closes TD
7f561c08de6b Initial load
duke
parents:
diff changeset
   275
        if ( openTag.equalsIgnoreCase( "TH" ) || openTag.equalsIgnoreCase( "TD" ) )
7f561c08de6b Initial load
duke
parents:
diff changeset
   276
            return isElement( tagName, CLOSE_TH_TD );
7f561c08de6b Initial load
duke
parents:
diff changeset
   277
        return false;
7f561c08de6b Initial load
duke
parents:
diff changeset
   278
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   279
7f561c08de6b Initial load
duke
parents:
diff changeset
   280
7f561c08de6b Initial load
duke
parents:
diff changeset
   281
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   282
     * Returns true if the specified attribute it a URI and should be
7f561c08de6b Initial load
duke
parents:
diff changeset
   283
     * escaped appropriately. In HTML URIs are escaped differently
7f561c08de6b Initial load
duke
parents:
diff changeset
   284
     * than normal attributes.
7f561c08de6b Initial load
duke
parents:
diff changeset
   285
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   286
     * @param tagName The element's tag name
7f561c08de6b Initial load
duke
parents:
diff changeset
   287
     * @param attrName The attribute's name
7f561c08de6b Initial load
duke
parents:
diff changeset
   288
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   289
    public static boolean isURI( String tagName, String attrName )
7f561c08de6b Initial load
duke
parents:
diff changeset
   290
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
   291
        // Stupid checks.
7f561c08de6b Initial load
duke
parents:
diff changeset
   292
        return ( attrName.equalsIgnoreCase( "href" ) || attrName.equalsIgnoreCase( "src" ) );
7f561c08de6b Initial load
duke
parents:
diff changeset
   293
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   294
7f561c08de6b Initial load
duke
parents:
diff changeset
   295
7f561c08de6b Initial load
duke
parents:
diff changeset
   296
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   297
     * Returns true if the specified attribute is a boolean and should be
7f561c08de6b Initial load
duke
parents:
diff changeset
   298
     * printed without the value. This applies to attributes that are true
7f561c08de6b Initial load
duke
parents:
diff changeset
   299
     * if they exist, such as selected (OPTION/INPUT).
7f561c08de6b Initial load
duke
parents:
diff changeset
   300
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   301
     * @param tagName The element's tag name
7f561c08de6b Initial load
duke
parents:
diff changeset
   302
     * @param attrName The attribute's name
7f561c08de6b Initial load
duke
parents:
diff changeset
   303
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   304
    public static boolean isBoolean( String tagName, String attrName )
7f561c08de6b Initial load
duke
parents:
diff changeset
   305
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
   306
        String[] attrNames;
7f561c08de6b Initial load
duke
parents:
diff changeset
   307
7f561c08de6b Initial load
duke
parents:
diff changeset
   308
        attrNames = (String[]) _boolAttrs.get( tagName.toUpperCase(Locale.ENGLISH) );
7f561c08de6b Initial load
duke
parents:
diff changeset
   309
        if ( attrNames == null )
7f561c08de6b Initial load
duke
parents:
diff changeset
   310
            return false;
7f561c08de6b Initial load
duke
parents:
diff changeset
   311
        for ( int i = 0 ; i < attrNames.length ; ++i )
7f561c08de6b Initial load
duke
parents:
diff changeset
   312
            if ( attrNames[ i ].equalsIgnoreCase( attrName ) )
7f561c08de6b Initial load
duke
parents:
diff changeset
   313
                return true;
7f561c08de6b Initial load
duke
parents:
diff changeset
   314
        return false;
7f561c08de6b Initial load
duke
parents:
diff changeset
   315
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   316
7f561c08de6b Initial load
duke
parents:
diff changeset
   317
7f561c08de6b Initial load
duke
parents:
diff changeset
   318
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   319
     * Returns the value of an HTML character reference by its name. If the
7f561c08de6b Initial load
duke
parents:
diff changeset
   320
     * reference is not found or was not defined as a character reference,
7f561c08de6b Initial load
duke
parents:
diff changeset
   321
     * returns EOF (-1).
7f561c08de6b Initial load
duke
parents:
diff changeset
   322
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   323
     * @param name Name of character reference
7f561c08de6b Initial load
duke
parents:
diff changeset
   324
     * @return Character code or EOF (-1)
7f561c08de6b Initial load
duke
parents:
diff changeset
   325
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   326
    public static int charFromName( String name )
7f561c08de6b Initial load
duke
parents:
diff changeset
   327
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
   328
        Object    value;
7f561c08de6b Initial load
duke
parents:
diff changeset
   329
7f561c08de6b Initial load
duke
parents:
diff changeset
   330
        initialize();
7f561c08de6b Initial load
duke
parents:
diff changeset
   331
        value = _byName.get( name );
7f561c08de6b Initial load
duke
parents:
diff changeset
   332
        if ( value != null && value instanceof Integer )
7f561c08de6b Initial load
duke
parents:
diff changeset
   333
            return ( (Integer) value ).intValue();
7f561c08de6b Initial load
duke
parents:
diff changeset
   334
        else
7f561c08de6b Initial load
duke
parents:
diff changeset
   335
            return -1;
7f561c08de6b Initial load
duke
parents:
diff changeset
   336
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   337
7f561c08de6b Initial load
duke
parents:
diff changeset
   338
7f561c08de6b Initial load
duke
parents:
diff changeset
   339
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   340
     * Returns the name of an HTML character reference based on its character
7f561c08de6b Initial load
duke
parents:
diff changeset
   341
     * value. Only valid for entities defined from character references. If no
7f561c08de6b Initial load
duke
parents:
diff changeset
   342
     * such character value was defined, return null.
7f561c08de6b Initial load
duke
parents:
diff changeset
   343
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   344
     * @param value Character value of entity
7f561c08de6b Initial load
duke
parents:
diff changeset
   345
     * @return Entity's name or null
7f561c08de6b Initial load
duke
parents:
diff changeset
   346
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   347
    public static String fromChar(int value )
7f561c08de6b Initial load
duke
parents:
diff changeset
   348
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
   349
       if (value > 0xffff)
7f561c08de6b Initial load
duke
parents:
diff changeset
   350
            return null;
7f561c08de6b Initial load
duke
parents:
diff changeset
   351
7f561c08de6b Initial load
duke
parents:
diff changeset
   352
        String name;
7f561c08de6b Initial load
duke
parents:
diff changeset
   353
7f561c08de6b Initial load
duke
parents:
diff changeset
   354
        initialize();
7f561c08de6b Initial load
duke
parents:
diff changeset
   355
        name = (String) _byChar.get( new Integer( value ) );
7f561c08de6b Initial load
duke
parents:
diff changeset
   356
        return name;
7f561c08de6b Initial load
duke
parents:
diff changeset
   357
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   358
7f561c08de6b Initial load
duke
parents:
diff changeset
   359
7f561c08de6b Initial load
duke
parents:
diff changeset
   360
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   361
     * Initialize upon first access. Will load all the HTML character references
7f561c08de6b Initial load
duke
parents:
diff changeset
   362
     * into a list that is accessible by name or character value and is optimized
7f561c08de6b Initial load
duke
parents:
diff changeset
   363
     * for character substitution. This method may be called any number of times
7f561c08de6b Initial load
duke
parents:
diff changeset
   364
     * but will execute only once.
7f561c08de6b Initial load
duke
parents:
diff changeset
   365
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   366
    private static void initialize()
7f561c08de6b Initial load
duke
parents:
diff changeset
   367
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
   368
        InputStream     is = null;
7f561c08de6b Initial load
duke
parents:
diff changeset
   369
        BufferedReader  reader = null;
7f561c08de6b Initial load
duke
parents:
diff changeset
   370
        int             index;
7f561c08de6b Initial load
duke
parents:
diff changeset
   371
        String          name;
7f561c08de6b Initial load
duke
parents:
diff changeset
   372
        String          value;
7f561c08de6b Initial load
duke
parents:
diff changeset
   373
        int             code;
7f561c08de6b Initial load
duke
parents:
diff changeset
   374
        String          line;
7f561c08de6b Initial load
duke
parents:
diff changeset
   375
7f561c08de6b Initial load
duke
parents:
diff changeset
   376
        // Make sure not to initialize twice.
7f561c08de6b Initial load
duke
parents:
diff changeset
   377
        if ( _byName != null )
7f561c08de6b Initial load
duke
parents:
diff changeset
   378
            return;
7f561c08de6b Initial load
duke
parents:
diff changeset
   379
        try {
7f561c08de6b Initial load
duke
parents:
diff changeset
   380
            _byName = new Hashtable();
7f561c08de6b Initial load
duke
parents:
diff changeset
   381
            _byChar = new Hashtable();
7f561c08de6b Initial load
duke
parents:
diff changeset
   382
            is = HTMLdtd.class.getResourceAsStream( ENTITIES_RESOURCE );
7f561c08de6b Initial load
duke
parents:
diff changeset
   383
            if ( is == null ) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   384
                throw new RuntimeException(
7f561c08de6b Initial load
duke
parents:
diff changeset
   385
                                    DOMMessageFormatter.formatMessage(
7f561c08de6b Initial load
duke
parents:
diff changeset
   386
                                    DOMMessageFormatter.SERIALIZER_DOMAIN,
7f561c08de6b Initial load
duke
parents:
diff changeset
   387
                    "ResourceNotFound", new Object[] {ENTITIES_RESOURCE}));
7f561c08de6b Initial load
duke
parents:
diff changeset
   388
            }
7f561c08de6b Initial load
duke
parents:
diff changeset
   389
            reader = new BufferedReader( new InputStreamReader( is, "ASCII" ) );
7f561c08de6b Initial load
duke
parents:
diff changeset
   390
            line = reader.readLine();
7f561c08de6b Initial load
duke
parents:
diff changeset
   391
            while ( line != null ) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   392
                if ( line.length() == 0 || line.charAt( 0 ) == '#' ) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   393
                    line = reader.readLine();
7f561c08de6b Initial load
duke
parents:
diff changeset
   394
                    continue;
7f561c08de6b Initial load
duke
parents:
diff changeset
   395
                }
7f561c08de6b Initial load
duke
parents:
diff changeset
   396
                index = line.indexOf( ' ' );
7f561c08de6b Initial load
duke
parents:
diff changeset
   397
                if ( index > 1 ) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   398
                    name = line.substring( 0, index );
7f561c08de6b Initial load
duke
parents:
diff changeset
   399
                    ++index;
7f561c08de6b Initial load
duke
parents:
diff changeset
   400
                    if ( index < line.length() ) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   401
                        value = line.substring( index );
7f561c08de6b Initial load
duke
parents:
diff changeset
   402
                        index = value.indexOf( ' ' );
7f561c08de6b Initial load
duke
parents:
diff changeset
   403
                        if ( index > 0 )
7f561c08de6b Initial load
duke
parents:
diff changeset
   404
                            value = value.substring( 0, index );
7f561c08de6b Initial load
duke
parents:
diff changeset
   405
                        code = Integer.parseInt( value );
7f561c08de6b Initial load
duke
parents:
diff changeset
   406
                                        defineEntity( name, (char) code );
7f561c08de6b Initial load
duke
parents:
diff changeset
   407
                    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   408
                }
7f561c08de6b Initial load
duke
parents:
diff changeset
   409
                line = reader.readLine();
7f561c08de6b Initial load
duke
parents:
diff changeset
   410
            }
7f561c08de6b Initial load
duke
parents:
diff changeset
   411
            is.close();
7f561c08de6b Initial load
duke
parents:
diff changeset
   412
        }  catch ( Exception except ) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   413
                        throw new RuntimeException(
7f561c08de6b Initial load
duke
parents:
diff changeset
   414
                                DOMMessageFormatter.formatMessage(
7f561c08de6b Initial load
duke
parents:
diff changeset
   415
                                DOMMessageFormatter.SERIALIZER_DOMAIN,
7f561c08de6b Initial load
duke
parents:
diff changeset
   416
                "ResourceNotLoaded", new Object[] {ENTITIES_RESOURCE, except.toString()}));
7f561c08de6b Initial load
duke
parents:
diff changeset
   417
        } finally {
7f561c08de6b Initial load
duke
parents:
diff changeset
   418
            if ( is != null ) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   419
                try {
7f561c08de6b Initial load
duke
parents:
diff changeset
   420
                    is.close();
7f561c08de6b Initial load
duke
parents:
diff changeset
   421
                } catch ( Exception except ) { }
7f561c08de6b Initial load
duke
parents:
diff changeset
   422
            }
7f561c08de6b Initial load
duke
parents:
diff changeset
   423
        }
7f561c08de6b Initial load
duke
parents:
diff changeset
   424
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   425
7f561c08de6b Initial load
duke
parents:
diff changeset
   426
7f561c08de6b Initial load
duke
parents:
diff changeset
   427
    /**
7f561c08de6b Initial load
duke
parents:
diff changeset
   428
     * Defines a new character reference. The reference's name and value are
7f561c08de6b Initial load
duke
parents:
diff changeset
   429
     * supplied. Nothing happens if the character reference is already defined.
7f561c08de6b Initial load
duke
parents:
diff changeset
   430
     * <P>
7f561c08de6b Initial load
duke
parents:
diff changeset
   431
     * Unlike internal entities, character references are a string to single
7f561c08de6b Initial load
duke
parents:
diff changeset
   432
     * character mapping. They are used to map non-ASCII characters both on
7f561c08de6b Initial load
duke
parents:
diff changeset
   433
     * parsing and printing, primarily for HTML documents. '&lt;amp;' is an
7f561c08de6b Initial load
duke
parents:
diff changeset
   434
     * example of a character reference.
7f561c08de6b Initial load
duke
parents:
diff changeset
   435
     *
7f561c08de6b Initial load
duke
parents:
diff changeset
   436
     * @param name The entity's name
7f561c08de6b Initial load
duke
parents:
diff changeset
   437
     * @param value The entity's value
7f561c08de6b Initial load
duke
parents:
diff changeset
   438
     */
7f561c08de6b Initial load
duke
parents:
diff changeset
   439
    private static void defineEntity( String name, char value )
7f561c08de6b Initial load
duke
parents:
diff changeset
   440
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
   441
        if ( _byName.get( name ) == null ) {
7f561c08de6b Initial load
duke
parents:
diff changeset
   442
            _byName.put( name, new Integer( value ) );
7f561c08de6b Initial load
duke
parents:
diff changeset
   443
            _byChar.put( new Integer( value ), name );
7f561c08de6b Initial load
duke
parents:
diff changeset
   444
        }
7f561c08de6b Initial load
duke
parents:
diff changeset
   445
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   446
7f561c08de6b Initial load
duke
parents:
diff changeset
   447
7f561c08de6b Initial load
duke
parents:
diff changeset
   448
    private static void defineElement( String name, int flags )
7f561c08de6b Initial load
duke
parents:
diff changeset
   449
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
   450
        _elemDefs.put( name, new Integer( flags ) );
7f561c08de6b Initial load
duke
parents:
diff changeset
   451
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   452
7f561c08de6b Initial load
duke
parents:
diff changeset
   453
7f561c08de6b Initial load
duke
parents:
diff changeset
   454
    private static void defineBoolean( String tagName, String attrName )
7f561c08de6b Initial load
duke
parents:
diff changeset
   455
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
   456
        defineBoolean( tagName, new String[] { attrName } );
7f561c08de6b Initial load
duke
parents:
diff changeset
   457
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   458
7f561c08de6b Initial load
duke
parents:
diff changeset
   459
7f561c08de6b Initial load
duke
parents:
diff changeset
   460
    private static void defineBoolean( String tagName, String[] attrNames )
7f561c08de6b Initial load
duke
parents:
diff changeset
   461
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
   462
        _boolAttrs.put( tagName, attrNames );
7f561c08de6b Initial load
duke
parents:
diff changeset
   463
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   464
7f561c08de6b Initial load
duke
parents:
diff changeset
   465
7f561c08de6b Initial load
duke
parents:
diff changeset
   466
    private static boolean isElement( String name, int flag )
7f561c08de6b Initial load
duke
parents:
diff changeset
   467
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
   468
        Integer flags;
7f561c08de6b Initial load
duke
parents:
diff changeset
   469
7f561c08de6b Initial load
duke
parents:
diff changeset
   470
        flags = (Integer) _elemDefs.get( name.toUpperCase(Locale.ENGLISH) );
7f561c08de6b Initial load
duke
parents:
diff changeset
   471
        if ( flags == null )
7f561c08de6b Initial load
duke
parents:
diff changeset
   472
            return false;
7f561c08de6b Initial load
duke
parents:
diff changeset
   473
        else
7f561c08de6b Initial load
duke
parents:
diff changeset
   474
            return ( ( flags.intValue() & flag ) == flag );
7f561c08de6b Initial load
duke
parents:
diff changeset
   475
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   476
7f561c08de6b Initial load
duke
parents:
diff changeset
   477
7f561c08de6b Initial load
duke
parents:
diff changeset
   478
    static
7f561c08de6b Initial load
duke
parents:
diff changeset
   479
    {
7f561c08de6b Initial load
duke
parents:
diff changeset
   480
        _elemDefs = new Hashtable();
7f561c08de6b Initial load
duke
parents:
diff changeset
   481
        defineElement( "ADDRESS", CLOSE_P );
7f561c08de6b Initial load
duke
parents:
diff changeset
   482
        defineElement( "AREA", EMPTY );
7f561c08de6b Initial load
duke
parents:
diff changeset
   483
        defineElement( "BASE",  EMPTY | ALLOWED_HEAD );
7f561c08de6b Initial load
duke
parents:
diff changeset
   484
        defineElement( "BASEFONT", EMPTY );
7f561c08de6b Initial load
duke
parents:
diff changeset
   485
        defineElement( "BLOCKQUOTE", CLOSE_P );
7f561c08de6b Initial load
duke
parents:
diff changeset
   486
        defineElement( "BODY", OPT_CLOSING );
7f561c08de6b Initial load
duke
parents:
diff changeset
   487
        defineElement( "BR", EMPTY );
7f561c08de6b Initial load
duke
parents:
diff changeset
   488
        defineElement( "COL", EMPTY );
7f561c08de6b Initial load
duke
parents:
diff changeset
   489
        defineElement( "COLGROUP", ELEM_CONTENT | OPT_CLOSING | CLOSE_TABLE );
7f561c08de6b Initial load
duke
parents:
diff changeset
   490
        defineElement( "DD", OPT_CLOSING | ONLY_OPENING | CLOSE_DD_DT );
7f561c08de6b Initial load
duke
parents:
diff changeset
   491
        defineElement( "DIV", CLOSE_P );
7f561c08de6b Initial load
duke
parents:
diff changeset
   492
        defineElement( "DL", ELEM_CONTENT | CLOSE_P );
7f561c08de6b Initial load
duke
parents:
diff changeset
   493
        defineElement( "DT", OPT_CLOSING | ONLY_OPENING | CLOSE_DD_DT );
7f561c08de6b Initial load
duke
parents:
diff changeset
   494
        defineElement( "FIELDSET", CLOSE_P );
7f561c08de6b Initial load
duke
parents:
diff changeset
   495
        defineElement( "FORM", CLOSE_P );
7f561c08de6b Initial load
duke
parents:
diff changeset
   496
        defineElement( "FRAME", EMPTY | OPT_CLOSING );
7f561c08de6b Initial load
duke
parents:
diff changeset
   497
        defineElement( "H1", CLOSE_P );
7f561c08de6b Initial load
duke
parents:
diff changeset
   498
        defineElement( "H2", CLOSE_P );
7f561c08de6b Initial load
duke
parents:
diff changeset
   499
        defineElement( "H3", CLOSE_P );
7f561c08de6b Initial load
duke
parents:
diff changeset
   500
        defineElement( "H4", CLOSE_P );
7f561c08de6b Initial load
duke
parents:
diff changeset
   501
        defineElement( "H5", CLOSE_P );
7f561c08de6b Initial load
duke
parents:
diff changeset
   502
        defineElement( "H6", CLOSE_P );
7f561c08de6b Initial load
duke
parents:
diff changeset
   503
        defineElement( "HEAD", ELEM_CONTENT | OPT_CLOSING );
7f561c08de6b Initial load
duke
parents:
diff changeset
   504
        defineElement( "HR", EMPTY | CLOSE_P );
7f561c08de6b Initial load
duke
parents:
diff changeset
   505
        defineElement( "HTML", ELEM_CONTENT | OPT_CLOSING );
7f561c08de6b Initial load
duke
parents:
diff changeset
   506
        defineElement( "IMG", EMPTY );
7f561c08de6b Initial load
duke
parents:
diff changeset
   507
        defineElement( "INPUT", EMPTY );
7f561c08de6b Initial load
duke
parents:
diff changeset
   508
        defineElement( "ISINDEX", EMPTY | ALLOWED_HEAD );
7f561c08de6b Initial load
duke
parents:
diff changeset
   509
        defineElement( "LI", OPT_CLOSING | ONLY_OPENING | CLOSE_SELF );
7f561c08de6b Initial load
duke
parents:
diff changeset
   510
        defineElement( "LINK", EMPTY | ALLOWED_HEAD );
7f561c08de6b Initial load
duke
parents:
diff changeset
   511
        defineElement( "MAP", ALLOWED_HEAD );
7f561c08de6b Initial load
duke
parents:
diff changeset
   512
        defineElement( "META", EMPTY | ALLOWED_HEAD );
7f561c08de6b Initial load
duke
parents:
diff changeset
   513
        defineElement( "OL", ELEM_CONTENT | CLOSE_P );
7f561c08de6b Initial load
duke
parents:
diff changeset
   514
        defineElement( "OPTGROUP", ELEM_CONTENT );
7f561c08de6b Initial load
duke
parents:
diff changeset
   515
        defineElement( "OPTION", OPT_CLOSING | ONLY_OPENING | CLOSE_SELF );
7f561c08de6b Initial load
duke
parents:
diff changeset
   516
        defineElement( "P", OPT_CLOSING | CLOSE_P | CLOSE_SELF );
7f561c08de6b Initial load
duke
parents:
diff changeset
   517
        defineElement( "PARAM", EMPTY );
7f561c08de6b Initial load
duke
parents:
diff changeset
   518
        defineElement( "PRE", PRESERVE | CLOSE_P );
7f561c08de6b Initial load
duke
parents:
diff changeset
   519
        defineElement( "SCRIPT", ALLOWED_HEAD | PRESERVE );
7f561c08de6b Initial load
duke
parents:
diff changeset
   520
        defineElement( "NOSCRIPT", ALLOWED_HEAD | PRESERVE );
7f561c08de6b Initial load
duke
parents:
diff changeset
   521
        defineElement( "SELECT", ELEM_CONTENT );
7f561c08de6b Initial load
duke
parents:
diff changeset
   522
        defineElement( "STYLE", ALLOWED_HEAD | PRESERVE );
7f561c08de6b Initial load
duke
parents:
diff changeset
   523
        defineElement( "TABLE", ELEM_CONTENT | CLOSE_P );
7f561c08de6b Initial load
duke
parents:
diff changeset
   524
        defineElement( "TBODY", ELEM_CONTENT | OPT_CLOSING | CLOSE_TABLE );
7f561c08de6b Initial load
duke
parents:
diff changeset
   525
        defineElement( "TD", OPT_CLOSING | CLOSE_TH_TD );
7f561c08de6b Initial load
duke
parents:
diff changeset
   526
        defineElement( "TEXTAREA", PRESERVE );
7f561c08de6b Initial load
duke
parents:
diff changeset
   527
        defineElement( "TFOOT", ELEM_CONTENT | OPT_CLOSING | CLOSE_TABLE );
7f561c08de6b Initial load
duke
parents:
diff changeset
   528
        defineElement( "TH", OPT_CLOSING | CLOSE_TH_TD );
7f561c08de6b Initial load
duke
parents:
diff changeset
   529
        defineElement( "THEAD", ELEM_CONTENT | OPT_CLOSING | CLOSE_TABLE );
7f561c08de6b Initial load
duke
parents:
diff changeset
   530
        defineElement( "TITLE", ALLOWED_HEAD );
7f561c08de6b Initial load
duke
parents:
diff changeset
   531
        defineElement( "TR", ELEM_CONTENT | OPT_CLOSING | CLOSE_TABLE );
7f561c08de6b Initial load
duke
parents:
diff changeset
   532
        defineElement( "UL", ELEM_CONTENT | CLOSE_P );
7f561c08de6b Initial load
duke
parents:
diff changeset
   533
7f561c08de6b Initial load
duke
parents:
diff changeset
   534
        _boolAttrs = new Hashtable();
7f561c08de6b Initial load
duke
parents:
diff changeset
   535
        defineBoolean( "AREA", "href" );
7f561c08de6b Initial load
duke
parents:
diff changeset
   536
        defineBoolean( "BUTTON", "disabled" );
7f561c08de6b Initial load
duke
parents:
diff changeset
   537
        defineBoolean( "DIR", "compact" );
7f561c08de6b Initial load
duke
parents:
diff changeset
   538
        defineBoolean( "DL", "compact" );
7f561c08de6b Initial load
duke
parents:
diff changeset
   539
        defineBoolean( "FRAME", "noresize" );
7f561c08de6b Initial load
duke
parents:
diff changeset
   540
        defineBoolean( "HR", "noshade" );
7f561c08de6b Initial load
duke
parents:
diff changeset
   541
        defineBoolean( "IMAGE", "ismap" );
7f561c08de6b Initial load
duke
parents:
diff changeset
   542
        defineBoolean( "INPUT", new String[] { "defaultchecked", "checked", "readonly", "disabled" } );
7f561c08de6b Initial load
duke
parents:
diff changeset
   543
        defineBoolean( "LINK", "link" );
7f561c08de6b Initial load
duke
parents:
diff changeset
   544
        defineBoolean( "MENU", "compact" );
7f561c08de6b Initial load
duke
parents:
diff changeset
   545
        defineBoolean( "OBJECT", "declare" );
7f561c08de6b Initial load
duke
parents:
diff changeset
   546
        defineBoolean( "OL", "compact" );
7f561c08de6b Initial load
duke
parents:
diff changeset
   547
        defineBoolean( "OPTGROUP", "disabled" );
7f561c08de6b Initial load
duke
parents:
diff changeset
   548
        defineBoolean( "OPTION", new String[] { "default-selected", "selected", "disabled" } );
7f561c08de6b Initial load
duke
parents:
diff changeset
   549
        defineBoolean( "SCRIPT", "defer" );
7f561c08de6b Initial load
duke
parents:
diff changeset
   550
        defineBoolean( "SELECT", new String[] { "multiple", "disabled" } );
7f561c08de6b Initial load
duke
parents:
diff changeset
   551
        defineBoolean( "STYLE", "disabled" );
7f561c08de6b Initial load
duke
parents:
diff changeset
   552
        defineBoolean( "TD", "nowrap" );
7f561c08de6b Initial load
duke
parents:
diff changeset
   553
        defineBoolean( "TH", "nowrap" );
7f561c08de6b Initial load
duke
parents:
diff changeset
   554
        defineBoolean( "TEXTAREA", new String[] { "disabled", "readonly" } );
7f561c08de6b Initial load
duke
parents:
diff changeset
   555
        defineBoolean( "UL", "compact" );
7f561c08de6b Initial load
duke
parents:
diff changeset
   556
7f561c08de6b Initial load
duke
parents:
diff changeset
   557
        initialize();
7f561c08de6b Initial load
duke
parents:
diff changeset
   558
    }
7f561c08de6b Initial load
duke
parents:
diff changeset
   559
7f561c08de6b Initial load
duke
parents:
diff changeset
   560
7f561c08de6b Initial load
duke
parents:
diff changeset
   561
7f561c08de6b Initial load
duke
parents:
diff changeset
   562
}