1 |
| |
2 |
| |
3 |
| |
4 |
| |
5 |
| |
6 |
| |
7 |
| |
8 |
| |
9 |
| |
10 |
| |
11 |
| |
12 |
| |
13 |
| |
14 |
| |
15 |
| |
16 |
| |
17 |
| |
18 |
| |
19 |
| |
20 |
| |
21 |
| |
22 |
| |
23 |
| |
24 |
| |
25 |
| |
26 |
| |
27 |
| |
28 |
| |
29 |
| |
30 |
| |
31 |
| |
32 |
| |
33 |
| |
34 |
| |
35 |
| |
36 |
| |
37 |
| |
38 |
| |
39 |
| |
40 |
| |
41 |
| |
42 |
| |
43 |
| |
44 |
| |
45 |
| |
46 |
| |
47 |
| |
48 |
| |
49 |
| |
50 |
| |
51 |
| |
52 |
| |
53 |
| |
54 |
| package org.w3c.tidy; |
55 |
| |
56 |
| import java.util.ArrayList; |
57 |
| import java.util.Hashtable; |
58 |
| import java.util.Iterator; |
59 |
| import java.util.List; |
60 |
| import java.util.Map; |
61 |
| |
62 |
| |
63 |
| |
64 |
| |
65 |
| |
66 |
| |
67 |
| |
68 |
| |
69 |
| |
70 |
| public final class TagTable |
71 |
| { |
72 |
| |
73 |
| |
74 |
| |
75 |
| |
76 |
| public static final Dict XML_TAGS = new Dict(null, Dict.VERS_ALL, Dict.CM_BLOCK, null, null); |
77 |
| |
78 |
| |
79 |
| |
80 |
| |
81 |
| private static final Dict[] TAGS = { |
82 |
| new Dict( |
83 |
| "html", |
84 |
| Dict.VERS_ALL, |
85 |
| (Dict.CM_HTML | Dict.CM_OPT | Dict.CM_OMITST), |
86 |
| ParserImpl.HTML, |
87 |
| TagCheckImpl.HTML), |
88 |
| new Dict("head", Dict.VERS_ALL, (Dict.CM_HTML | Dict.CM_OPT | Dict.CM_OMITST), ParserImpl.HEAD, null), |
89 |
| new Dict("title", Dict.VERS_ALL, Dict.CM_HEAD, ParserImpl.TITLE, null), |
90 |
| new Dict("base", Dict.VERS_ALL, (Dict.CM_HEAD | Dict.CM_EMPTY), ParserImpl.EMPTY, null), |
91 |
| new Dict("link", Dict.VERS_ALL, (Dict.CM_HEAD | Dict.CM_EMPTY), ParserImpl.EMPTY, TagCheckImpl.LINK), |
92 |
| new Dict("meta", Dict.VERS_ALL, (Dict.CM_HEAD | Dict.CM_EMPTY), ParserImpl.EMPTY, TagCheckImpl.META), |
93 |
| new Dict( |
94 |
| "style", |
95 |
| (short) (Dict.VERS_HTML40 & ~Dict.VERS_BASIC), |
96 |
| Dict.CM_HEAD, |
97 |
| ParserImpl.SCRIPT, |
98 |
| TagCheckImpl.STYLE), |
99 |
| new Dict( |
100 |
| "script", |
101 |
| (short) (Dict.VERS_HTML40 & ~Dict.VERS_BASIC), |
102 |
| (Dict.CM_HEAD | Dict.CM_MIXED | Dict.CM_BLOCK | Dict.CM_INLINE), |
103 |
| ParserImpl.SCRIPT, |
104 |
| TagCheckImpl.SCRIPT), |
105 |
| new Dict( |
106 |
| "server", |
107 |
| Dict.VERS_NETSCAPE, |
108 |
| (Dict.CM_HEAD | Dict.CM_MIXED | Dict.CM_BLOCK | Dict.CM_INLINE), |
109 |
| ParserImpl.SCRIPT, |
110 |
| null), |
111 |
| new Dict("body", Dict.VERS_ALL, (Dict.CM_HTML | Dict.CM_OPT | Dict.CM_OMITST), ParserImpl.BODY, null), |
112 |
| new Dict("frameset", Dict.VERS_FRAMESET, (Dict.CM_HTML | Dict.CM_FRAMES), ParserImpl.FRAMESET, null), |
113 |
| new Dict("p", Dict.VERS_ALL, (Dict.CM_BLOCK | Dict.CM_OPT), ParserImpl.INLINE, null), |
114 |
| new Dict("h1", Dict.VERS_ALL, (Dict.CM_BLOCK | Dict.CM_HEADING), ParserImpl.INLINE, null), |
115 |
| new Dict("h2", Dict.VERS_ALL, (Dict.CM_BLOCK | Dict.CM_HEADING), ParserImpl.INLINE, null), |
116 |
| new Dict("h3", Dict.VERS_ALL, (Dict.CM_BLOCK | Dict.CM_HEADING), ParserImpl.INLINE, null), |
117 |
| new Dict("h4", Dict.VERS_ALL, (Dict.CM_BLOCK | Dict.CM_HEADING), ParserImpl.INLINE, null), |
118 |
| new Dict("h5", Dict.VERS_ALL, (Dict.CM_BLOCK | Dict.CM_HEADING), ParserImpl.INLINE, null), |
119 |
| new Dict("h6", Dict.VERS_ALL, (Dict.CM_BLOCK | Dict.CM_HEADING), ParserImpl.INLINE, null), |
120 |
| new Dict("ul", Dict.VERS_ALL, Dict.CM_BLOCK, ParserImpl.LIST, null), |
121 |
| new Dict("ol", Dict.VERS_ALL, Dict.CM_BLOCK, ParserImpl.LIST, null), |
122 |
| new Dict("dl", Dict.VERS_ALL, Dict.CM_BLOCK, ParserImpl.DEFLIST, null), |
123 |
| new Dict("dir", Dict.VERS_LOOSE, (Dict.CM_BLOCK | Dict.CM_OBSOLETE), ParserImpl.LIST, null), |
124 |
| new Dict("menu", Dict.VERS_LOOSE, (Dict.CM_BLOCK | Dict.CM_OBSOLETE), ParserImpl.LIST, null), |
125 |
| new Dict("pre", Dict.VERS_ALL, Dict.CM_BLOCK, ParserImpl.PRE, null), |
126 |
| new Dict("listing", Dict.VERS_ALL, (Dict.CM_BLOCK | Dict.CM_OBSOLETE), ParserImpl.PRE, null), |
127 |
| new Dict("xmp", Dict.VERS_ALL, (Dict.CM_BLOCK | Dict.CM_OBSOLETE), ParserImpl.PRE, null), |
128 |
| new Dict("plaintext", Dict.VERS_ALL, (Dict.CM_BLOCK | Dict.CM_OBSOLETE), ParserImpl.PRE, null), |
129 |
| new Dict("address", Dict.VERS_ALL, Dict.CM_BLOCK, ParserImpl.BLOCK, null), |
130 |
| new Dict("blockquote", Dict.VERS_ALL, Dict.CM_BLOCK, ParserImpl.BLOCK, null), |
131 |
| new Dict("form", Dict.VERS_ALL, Dict.CM_BLOCK, ParserImpl.BLOCK, TagCheckImpl.FORM), |
132 |
| new Dict("isindex", Dict.VERS_LOOSE, (Dict.CM_BLOCK | Dict.CM_EMPTY), ParserImpl.EMPTY, null), |
133 |
| new Dict("fieldset", (short) (Dict.VERS_HTML40 & ~Dict.VERS_BASIC), Dict.CM_BLOCK, ParserImpl.BLOCK, null), |
134 |
| new Dict("table", Dict.VERS_FROM32, Dict.CM_BLOCK, ParserImpl.TABLETAG, TagCheckImpl.TABLE), |
135 |
| new Dict( |
136 |
| "hr", |
137 |
| (short) (Dict.VERS_ALL & ~Dict.VERS_BASIC), |
138 |
| (Dict.CM_BLOCK | Dict.CM_EMPTY), |
139 |
| ParserImpl.EMPTY, |
140 |
| TagCheckImpl.HR), |
141 |
| new Dict("div", Dict.VERS_FROM32, Dict.CM_BLOCK, ParserImpl.BLOCK, null), |
142 |
| new Dict("multicol", Dict.VERS_NETSCAPE, Dict.CM_BLOCK, ParserImpl.BLOCK, null), |
143 |
| new Dict("nosave", Dict.VERS_NETSCAPE, Dict.CM_BLOCK, ParserImpl.BLOCK, null), |
144 |
| new Dict("layer", Dict.VERS_NETSCAPE, Dict.CM_BLOCK, ParserImpl.BLOCK, null), |
145 |
| new Dict("ilayer", Dict.VERS_NETSCAPE, Dict.CM_INLINE, ParserImpl.INLINE, null), |
146 |
| new Dict( |
147 |
| "nolayer", |
148 |
| Dict.VERS_NETSCAPE, |
149 |
| (Dict.CM_BLOCK | Dict.CM_INLINE | Dict.CM_MIXED), |
150 |
| ParserImpl.BLOCK, |
151 |
| null), |
152 |
| new Dict("align", Dict.VERS_NETSCAPE, Dict.CM_BLOCK, ParserImpl.BLOCK, null), |
153 |
| new Dict("center", Dict.VERS_LOOSE, Dict.CM_BLOCK, ParserImpl.BLOCK, null), |
154 |
| new Dict( |
155 |
| "ins", |
156 |
| (short) (Dict.VERS_HTML40 & ~Dict.VERS_BASIC), |
157 |
| (Dict.CM_INLINE | Dict.CM_BLOCK | Dict.CM_MIXED), |
158 |
| ParserImpl.INLINE, |
159 |
| null), |
160 |
| new Dict( |
161 |
| "del", |
162 |
| (short) (Dict.VERS_HTML40 & ~Dict.VERS_BASIC), |
163 |
| (Dict.CM_INLINE | Dict.CM_BLOCK | Dict.CM_MIXED), |
164 |
| ParserImpl.INLINE, |
165 |
| null), |
166 |
| new Dict("li", Dict.VERS_ALL, (Dict.CM_LIST | Dict.CM_OPT | Dict.CM_NO_INDENT), ParserImpl.BLOCK, null), |
167 |
| new Dict("dt", Dict.VERS_ALL, (Dict.CM_DEFLIST | Dict.CM_OPT | Dict.CM_NO_INDENT), ParserImpl.INLINE, null), |
168 |
| new Dict("dd", Dict.VERS_ALL, (Dict.CM_DEFLIST | Dict.CM_OPT | Dict.CM_NO_INDENT), ParserImpl.BLOCK, null), |
169 |
| new Dict("caption", Dict.VERS_FROM32, Dict.CM_TABLE, ParserImpl.INLINE, TagCheckImpl.CAPTION), |
170 |
| new Dict("colgroup", Dict.VERS_HTML40, (Dict.CM_TABLE | Dict.CM_OPT), ParserImpl.COLGROUP, null), |
171 |
| new Dict("col", Dict.VERS_HTML40, (Dict.CM_TABLE | Dict.CM_EMPTY), ParserImpl.EMPTY, null), |
172 |
| new Dict( |
173 |
| "thead", |
174 |
| (short) (Dict.VERS_HTML40 & ~Dict.VERS_BASIC), |
175 |
| (Dict.CM_TABLE | Dict.CM_ROWGRP | Dict.CM_OPT), |
176 |
| ParserImpl.ROWGROUP, |
177 |
| null), |
178 |
| new Dict( |
179 |
| "tfoot", |
180 |
| (short) (Dict.VERS_HTML40 & ~Dict.VERS_BASIC), |
181 |
| (Dict.CM_TABLE | Dict.CM_ROWGRP | Dict.CM_OPT), |
182 |
| ParserImpl.ROWGROUP, |
183 |
| null), |
184 |
| new Dict( |
185 |
| "tbody", |
186 |
| (short) (Dict.VERS_HTML40 & ~Dict.VERS_BASIC), |
187 |
| (Dict.CM_TABLE | Dict.CM_ROWGRP | Dict.CM_OPT), |
188 |
| ParserImpl.ROWGROUP, |
189 |
| null), |
190 |
| new Dict("tr", Dict.VERS_FROM32, (Dict.CM_TABLE | Dict.CM_OPT), ParserImpl.ROW, null), |
191 |
| new Dict( |
192 |
| "td", |
193 |
| Dict.VERS_FROM32, |
194 |
| (Dict.CM_ROW | Dict.CM_OPT | Dict.CM_NO_INDENT), |
195 |
| ParserImpl.BLOCK, |
196 |
| TagCheckImpl.TABLECELL), |
197 |
| new Dict( |
198 |
| "th", |
199 |
| Dict.VERS_FROM32, |
200 |
| (Dict.CM_ROW | Dict.CM_OPT | Dict.CM_NO_INDENT), |
201 |
| ParserImpl.BLOCK, |
202 |
| TagCheckImpl.TABLECELL), |
203 |
| new Dict("q", Dict.VERS_HTML40, Dict.CM_INLINE, ParserImpl.INLINE, null), |
204 |
| new Dict("a", Dict.VERS_ALL, Dict.CM_INLINE, ParserImpl.INLINE, TagCheckImpl.ANCHOR), |
205 |
| new Dict("br", Dict.VERS_ALL, (Dict.CM_INLINE | Dict.CM_EMPTY), ParserImpl.EMPTY, null), |
206 |
| new Dict( |
207 |
| "img", |
208 |
| Dict.VERS_ALL, |
209 |
| (Dict.CM_INLINE | Dict.CM_IMG | Dict.CM_EMPTY), |
210 |
| ParserImpl.EMPTY, |
211 |
| TagCheckImpl.IMG), |
212 |
| new Dict( |
213 |
| "object", |
214 |
| Dict.VERS_HTML40, |
215 |
| (Dict.CM_OBJECT | Dict.CM_HEAD | Dict.CM_IMG | Dict.CM_INLINE | Dict.CM_PARAM), |
216 |
| ParserImpl.BLOCK, |
217 |
| null), |
218 |
| new Dict( |
219 |
| "applet", |
220 |
| Dict.VERS_LOOSE, |
221 |
| (Dict.CM_OBJECT | Dict.CM_IMG | Dict.CM_INLINE | Dict.CM_PARAM), |
222 |
| ParserImpl.BLOCK, |
223 |
| null), |
224 |
| new Dict( |
225 |
| "servlet", |
226 |
| Dict.VERS_SUN, |
227 |
| (Dict.CM_OBJECT | Dict.CM_IMG | Dict.CM_INLINE | Dict.CM_PARAM), |
228 |
| ParserImpl.BLOCK, |
229 |
| null), |
230 |
| new Dict("param", Dict.VERS_FROM32, (Dict.CM_INLINE | Dict.CM_EMPTY), ParserImpl.EMPTY, null), |
231 |
| new Dict("embed", Dict.VERS_NETSCAPE, (Dict.CM_INLINE | Dict.CM_IMG | Dict.CM_EMPTY), ParserImpl.EMPTY, null), |
232 |
| new Dict("noembed", Dict.VERS_NETSCAPE, Dict.CM_INLINE, ParserImpl.INLINE, null), |
233 |
| new Dict("iframe", Dict.VERS_HTML40_LOOSE, Dict.CM_INLINE, ParserImpl.BLOCK, null), |
234 |
| new Dict("frame", Dict.VERS_FRAMESET, (Dict.CM_FRAMES | Dict.CM_EMPTY), ParserImpl.EMPTY, null), |
235 |
| new Dict("noframes", Dict.VERS_IFRAME, (Dict.CM_BLOCK | Dict.CM_FRAMES), ParserImpl.NOFRAMES, null), |
236 |
| new Dict( |
237 |
| "noscript", |
238 |
| (short) (Dict.VERS_HTML40 & ~Dict.VERS_BASIC), |
239 |
| (Dict.CM_BLOCK | Dict.CM_INLINE | Dict.CM_MIXED), |
240 |
| ParserImpl.BLOCK, |
241 |
| null), |
242 |
| new Dict("b", (short) (Dict.VERS_ALL & ~Dict.VERS_BASIC), Dict.CM_INLINE, ParserImpl.INLINE, null), |
243 |
| new Dict("i", (short) (Dict.VERS_ALL & ~Dict.VERS_BASIC), Dict.CM_INLINE, ParserImpl.INLINE, null), |
244 |
| new Dict("u", Dict.VERS_LOOSE, Dict.CM_INLINE, ParserImpl.INLINE, null), |
245 |
| new Dict("tt", (short) (Dict.VERS_ALL & ~Dict.VERS_BASIC), Dict.CM_INLINE, ParserImpl.INLINE, null), |
246 |
| new Dict("s", Dict.VERS_LOOSE, Dict.CM_INLINE, ParserImpl.INLINE, null), |
247 |
| new Dict("strike", Dict.VERS_LOOSE, Dict.CM_INLINE, ParserImpl.INLINE, null), |
248 |
| new Dict("big", (short) (Dict.VERS_HTML40 & ~Dict.VERS_BASIC), Dict.CM_INLINE, ParserImpl.INLINE, null), |
249 |
| new Dict("small", (short) (Dict.VERS_HTML40 & ~Dict.VERS_BASIC), Dict.CM_INLINE, ParserImpl.INLINE, null), |
250 |
| new Dict("sub", (short) (Dict.VERS_HTML40 & ~Dict.VERS_BASIC), Dict.CM_INLINE, ParserImpl.INLINE, null), |
251 |
| new Dict("sup", (short) (Dict.VERS_HTML40 & ~Dict.VERS_BASIC), Dict.CM_INLINE, ParserImpl.INLINE, null), |
252 |
| new Dict("em", Dict.VERS_ALL, Dict.CM_INLINE, ParserImpl.INLINE, null), |
253 |
| new Dict("strong", Dict.VERS_ALL, Dict.CM_INLINE, ParserImpl.INLINE, null), |
254 |
| new Dict("dfn", Dict.VERS_ALL, Dict.CM_INLINE, ParserImpl.INLINE, null), |
255 |
| new Dict("code", Dict.VERS_ALL, Dict.CM_INLINE, ParserImpl.INLINE, null), |
256 |
| new Dict("samp", Dict.VERS_ALL, Dict.CM_INLINE, ParserImpl.INLINE, null), |
257 |
| new Dict("kbd", Dict.VERS_ALL, Dict.CM_INLINE, ParserImpl.INLINE, null), |
258 |
| new Dict("var", Dict.VERS_ALL, Dict.CM_INLINE, ParserImpl.INLINE, null), |
259 |
| new Dict("cite", Dict.VERS_ALL, Dict.CM_INLINE, ParserImpl.INLINE, null), |
260 |
| new Dict("abbr", Dict.VERS_HTML40, Dict.CM_INLINE, ParserImpl.INLINE, null), |
261 |
| new Dict("acronym", Dict.VERS_HTML40, Dict.CM_INLINE, ParserImpl.INLINE, null), |
262 |
| new Dict("span", Dict.VERS_FROM32, Dict.CM_INLINE, ParserImpl.INLINE, null), |
263 |
| new Dict("blink", Dict.VERS_PROPRIETARY, Dict.CM_INLINE, ParserImpl.INLINE, null), |
264 |
| new Dict("nobr", Dict.VERS_PROPRIETARY, Dict.CM_INLINE, ParserImpl.INLINE, null), |
265 |
| new Dict("wbr", Dict.VERS_PROPRIETARY, (Dict.CM_INLINE | Dict.CM_EMPTY), ParserImpl.EMPTY, null), |
266 |
| new Dict("marquee", Dict.VERS_MICROSOFT, (Dict.CM_INLINE | Dict.CM_OPT), ParserImpl.INLINE, null), |
267 |
| new Dict("bgsound", Dict.VERS_MICROSOFT, (Dict.CM_HEAD | Dict.CM_EMPTY), ParserImpl.EMPTY, null), |
268 |
| new Dict("comment", Dict.VERS_MICROSOFT, Dict.CM_INLINE, ParserImpl.INLINE, null), |
269 |
| new Dict("spacer", Dict.VERS_NETSCAPE, (Dict.CM_INLINE | Dict.CM_EMPTY), ParserImpl.EMPTY, null), |
270 |
| new Dict("keygen", Dict.VERS_NETSCAPE, (Dict.CM_INLINE | Dict.CM_EMPTY), ParserImpl.EMPTY, null), |
271 |
| new Dict( |
272 |
| "nolayer", |
273 |
| Dict.VERS_NETSCAPE, |
274 |
| (Dict.CM_BLOCK | Dict.CM_INLINE | Dict.CM_MIXED), |
275 |
| ParserImpl.BLOCK, |
276 |
| null), |
277 |
| new Dict("ilayer", Dict.VERS_NETSCAPE, Dict.CM_INLINE, ParserImpl.INLINE, null), |
278 |
| new Dict( |
279 |
| "map", |
280 |
| (short) (Dict.VERS_HTML40 & ~Dict.VERS_BASIC), |
281 |
| Dict.CM_INLINE, |
282 |
| ParserImpl.BLOCK, |
283 |
| TagCheckImpl.MAP), |
284 |
| new Dict( |
285 |
| "area", |
286 |
| (short) (Dict.VERS_ALL & ~Dict.VERS_BASIC), |
287 |
| (Dict.CM_BLOCK | Dict.CM_EMPTY), |
288 |
| ParserImpl.EMPTY, |
289 |
| TagCheckImpl.AREA), |
290 |
| new Dict("input", Dict.VERS_ALL, (Dict.CM_INLINE | Dict.CM_IMG | Dict.CM_EMPTY), ParserImpl.EMPTY, null), |
291 |
| new Dict("select", Dict.VERS_ALL, (Dict.CM_INLINE | Dict.CM_FIELD), ParserImpl.SELECT, null), |
292 |
| new Dict("option", Dict.VERS_ALL, (Dict.CM_FIELD | Dict.CM_OPT), ParserImpl.TEXT, null), |
293 |
| new Dict( |
294 |
| "optgroup", |
295 |
| (short) (Dict.VERS_HTML40 & ~Dict.VERS_BASIC), |
296 |
| (Dict.CM_FIELD | Dict.CM_OPT), |
297 |
| ParserImpl.OPTGROUP, |
298 |
| null), |
299 |
| new Dict("textarea", Dict.VERS_ALL, (Dict.CM_INLINE | Dict.CM_FIELD), ParserImpl.TEXT, null), |
300 |
| new Dict("label", Dict.VERS_HTML40, Dict.CM_INLINE, ParserImpl.INLINE, null), |
301 |
| new Dict("legend", (short) (Dict.VERS_HTML40 & ~Dict.VERS_BASIC), Dict.CM_INLINE, ParserImpl.INLINE, null), |
302 |
| new Dict("button", (short) (Dict.VERS_HTML40 & ~Dict.VERS_BASIC), Dict.CM_INLINE, ParserImpl.INLINE, null), |
303 |
| new Dict("basefont", Dict.VERS_LOOSE, (Dict.CM_INLINE | Dict.CM_EMPTY), ParserImpl.EMPTY, null), |
304 |
| new Dict("font", Dict.VERS_LOOSE, Dict.CM_INLINE, ParserImpl.INLINE, null), |
305 |
| new Dict("bdo", (short) (Dict.VERS_HTML40 & ~Dict.VERS_BASIC), Dict.CM_INLINE, ParserImpl.INLINE, null), |
306 |
| |
307 |
| new Dict("ruby", Dict.VERS_XHTML11, Dict.CM_INLINE, ParserImpl.INLINE, null), |
308 |
| new Dict("rbc", Dict.VERS_XHTML11, Dict.CM_INLINE, ParserImpl.INLINE, null), |
309 |
| new Dict("rtc", Dict.VERS_XHTML11, Dict.CM_INLINE, ParserImpl.INLINE, null), |
310 |
| new Dict("rb", Dict.VERS_XHTML11, Dict.CM_INLINE, ParserImpl.INLINE, null), |
311 |
| new Dict("rt", Dict.VERS_XHTML11, Dict.CM_INLINE, ParserImpl.INLINE, null), |
312 |
| new Dict("", Dict.VERS_XHTML11, Dict.CM_INLINE, ParserImpl.INLINE, null), |
313 |
| new Dict("rp", Dict.VERS_XHTML11, Dict.CM_INLINE, ParserImpl.INLINE, null), |
314 |
| |
315 |
| }; |
316 |
| |
317 |
| |
318 |
| |
319 |
| |
320 |
| protected Dict tagHtml; |
321 |
| |
322 |
| |
323 |
| |
324 |
| |
325 |
| protected Dict tagHead; |
326 |
| |
327 |
| |
328 |
| |
329 |
| |
330 |
| protected Dict tagBody; |
331 |
| |
332 |
| |
333 |
| |
334 |
| |
335 |
| protected Dict tagFrameset; |
336 |
| |
337 |
| |
338 |
| |
339 |
| |
340 |
| protected Dict tagFrame; |
341 |
| |
342 |
| |
343 |
| |
344 |
| |
345 |
| protected Dict tagIframe; |
346 |
| |
347 |
| |
348 |
| |
349 |
| |
350 |
| protected Dict tagNoframes; |
351 |
| |
352 |
| |
353 |
| |
354 |
| |
355 |
| protected Dict tagMeta; |
356 |
| |
357 |
| |
358 |
| |
359 |
| |
360 |
| protected Dict tagTitle; |
361 |
| |
362 |
| |
363 |
| |
364 |
| |
365 |
| protected Dict tagBase; |
366 |
| |
367 |
| |
368 |
| |
369 |
| |
370 |
| protected Dict tagHr; |
371 |
| |
372 |
| |
373 |
| |
374 |
| |
375 |
| protected Dict tagPre; |
376 |
| |
377 |
| |
378 |
| |
379 |
| |
380 |
| protected Dict tagListing; |
381 |
| |
382 |
| |
383 |
| |
384 |
| |
385 |
| protected Dict tagH1; |
386 |
| |
387 |
| |
388 |
| |
389 |
| |
390 |
| protected Dict tagH2; |
391 |
| |
392 |
| |
393 |
| |
394 |
| |
395 |
| protected Dict tagP; |
396 |
| |
397 |
| |
398 |
| |
399 |
| |
400 |
| protected Dict tagUl; |
401 |
| |
402 |
| |
403 |
| |
404 |
| |
405 |
| protected Dict tagOl; |
406 |
| |
407 |
| |
408 |
| |
409 |
| |
410 |
| protected Dict tagDir; |
411 |
| |
412 |
| |
413 |
| |
414 |
| |
415 |
| protected Dict tagLi; |
416 |
| |
417 |
| |
418 |
| |
419 |
| |
420 |
| protected Dict tagDt; |
421 |
| |
422 |
| |
423 |
| |
424 |
| |
425 |
| protected Dict tagDd; |
426 |
| |
427 |
| |
428 |
| |
429 |
| |
430 |
| protected Dict tagDl; |
431 |
| |
432 |
| |
433 |
| |
434 |
| |
435 |
| protected Dict tagTd; |
436 |
| |
437 |
| |
438 |
| |
439 |
| |
440 |
| protected Dict tagTh; |
441 |
| |
442 |
| |
443 |
| |
444 |
| |
445 |
| protected Dict tagTr; |
446 |
| |
447 |
| |
448 |
| |
449 |
| |
450 |
| protected Dict tagCol; |
451 |
| |
452 |
| |
453 |
| |
454 |
| |
455 |
| protected Dict tagColgroup; |
456 |
| |
457 |
| |
458 |
| |
459 |
| |
460 |
| protected Dict tagBr; |
461 |
| |
462 |
| |
463 |
| |
464 |
| |
465 |
| protected Dict tagA; |
466 |
| |
467 |
| |
468 |
| |
469 |
| |
470 |
| protected Dict tagLink; |
471 |
| |
472 |
| |
473 |
| |
474 |
| |
475 |
| protected Dict tagB; |
476 |
| |
477 |
| |
478 |
| |
479 |
| |
480 |
| protected Dict tagI; |
481 |
| |
482 |
| |
483 |
| |
484 |
| |
485 |
| protected Dict tagStrong; |
486 |
| |
487 |
| |
488 |
| |
489 |
| |
490 |
| protected Dict tagEm; |
491 |
| |
492 |
| |
493 |
| |
494 |
| |
495 |
| protected Dict tagBig; |
496 |
| |
497 |
| |
498 |
| |
499 |
| |
500 |
| protected Dict tagSmall; |
501 |
| |
502 |
| |
503 |
| |
504 |
| |
505 |
| protected Dict tagParam; |
506 |
| |
507 |
| |
508 |
| |
509 |
| |
510 |
| protected Dict tagOption; |
511 |
| |
512 |
| |
513 |
| |
514 |
| |
515 |
| protected Dict tagOptgroup; |
516 |
| |
517 |
| |
518 |
| |
519 |
| |
520 |
| protected Dict tagImg; |
521 |
| |
522 |
| |
523 |
| |
524 |
| |
525 |
| protected Dict tagMap; |
526 |
| |
527 |
| |
528 |
| |
529 |
| |
530 |
| protected Dict tagArea; |
531 |
| |
532 |
| |
533 |
| |
534 |
| |
535 |
| protected Dict tagNobr; |
536 |
| |
537 |
| |
538 |
| |
539 |
| |
540 |
| protected Dict tagWbr; |
541 |
| |
542 |
| |
543 |
| |
544 |
| |
545 |
| protected Dict tagFont; |
546 |
| |
547 |
| |
548 |
| |
549 |
| |
550 |
| protected Dict tagSpacer; |
551 |
| |
552 |
| |
553 |
| |
554 |
| |
555 |
| protected Dict tagLayer; |
556 |
| |
557 |
| |
558 |
| |
559 |
| |
560 |
| protected Dict tagCenter; |
561 |
| |
562 |
| |
563 |
| |
564 |
| |
565 |
| protected Dict tagStyle; |
566 |
| |
567 |
| |
568 |
| |
569 |
| |
570 |
| protected Dict tagScript; |
571 |
| |
572 |
| |
573 |
| |
574 |
| |
575 |
| protected Dict tagNoscript; |
576 |
| |
577 |
| |
578 |
| |
579 |
| |
580 |
| protected Dict tagTable; |
581 |
| |
582 |
| |
583 |
| |
584 |
| |
585 |
| protected Dict tagCaption; |
586 |
| |
587 |
| |
588 |
| |
589 |
| |
590 |
| protected Dict tagForm; |
591 |
| |
592 |
| |
593 |
| |
594 |
| |
595 |
| protected Dict tagTextarea; |
596 |
| |
597 |
| |
598 |
| |
599 |
| |
600 |
| protected Dict tagBlockquote; |
601 |
| |
602 |
| |
603 |
| |
604 |
| |
605 |
| protected Dict tagApplet; |
606 |
| |
607 |
| |
608 |
| |
609 |
| |
610 |
| protected Dict tagObject; |
611 |
| |
612 |
| |
613 |
| |
614 |
| |
615 |
| protected Dict tagDiv; |
616 |
| |
617 |
| |
618 |
| |
619 |
| |
620 |
| protected Dict tagSpan; |
621 |
| |
622 |
| |
623 |
| |
624 |
| |
625 |
| protected Dict tagInput; |
626 |
| |
627 |
| |
628 |
| |
629 |
| |
630 |
| protected Dict tagQ; |
631 |
| |
632 |
| |
633 |
| |
634 |
| |
635 |
| protected Dict tagBlink; |
636 |
| |
637 |
| |
638 |
| |
639 |
| |
640 |
| protected Anchor anchorList; |
641 |
| |
642 |
| |
643 |
| |
644 |
| |
645 |
| private Configuration configuration; |
646 |
| |
647 |
| |
648 |
| |
649 |
| |
650 |
| private Map tagHashtable = new Hashtable(); |
651 |
| |
652 |
| |
653 |
| |
654 |
| |
655 |
250
| protected TagTable()
|
656 |
| { |
657 |
250
| for (int i = 0; i < TAGS.length; i++)
|
658 |
| { |
659 |
30250
| install(TAGS[i]);
|
660 |
| } |
661 |
250
| tagHtml = lookup("html");
|
662 |
250
| tagHead = lookup("head");
|
663 |
250
| tagBody = lookup("body");
|
664 |
250
| tagFrameset = lookup("frameset");
|
665 |
250
| tagFrame = lookup("frame");
|
666 |
250
| tagIframe = lookup("iframe");
|
667 |
250
| tagNoframes = lookup("noframes");
|
668 |
250
| tagMeta = lookup("meta");
|
669 |
250
| tagTitle = lookup("title");
|
670 |
250
| tagBase = lookup("base");
|
671 |
250
| tagHr = lookup("hr");
|
672 |
250
| tagPre = lookup("pre");
|
673 |
250
| tagListing = lookup("listing");
|
674 |
250
| tagH1 = lookup("h1");
|
675 |
250
| tagH2 = lookup("h2");
|
676 |
250
| tagP = lookup("p");
|
677 |
250
| tagUl = lookup("ul");
|
678 |
250
| tagOl = lookup("ol");
|
679 |
250
| tagDir = lookup("dir");
|
680 |
250
| tagLi = lookup("li");
|
681 |
250
| tagDt = lookup("dt");
|
682 |
250
| tagDd = lookup("dd");
|
683 |
250
| tagDl = lookup("dl");
|
684 |
250
| tagTd = lookup("td");
|
685 |
250
| tagTh = lookup("th");
|
686 |
250
| tagTr = lookup("tr");
|
687 |
250
| tagCol = lookup("col");
|
688 |
250
| tagColgroup = lookup("colgroup");
|
689 |
250
| tagBr = lookup("br");
|
690 |
250
| tagA = lookup("a");
|
691 |
250
| tagLink = lookup("link");
|
692 |
250
| tagB = lookup("b");
|
693 |
250
| tagI = lookup("i");
|
694 |
250
| tagStrong = lookup("strong");
|
695 |
250
| tagEm = lookup("em");
|
696 |
250
| tagBig = lookup("big");
|
697 |
250
| tagSmall = lookup("small");
|
698 |
250
| tagParam = lookup("param");
|
699 |
250
| tagOption = lookup("option");
|
700 |
250
| tagOptgroup = lookup("optgroup");
|
701 |
250
| tagImg = lookup("img");
|
702 |
250
| tagMap = lookup("map");
|
703 |
250
| tagArea = lookup("area");
|
704 |
250
| tagNobr = lookup("nobr");
|
705 |
250
| tagWbr = lookup("wbr");
|
706 |
250
| tagFont = lookup("font");
|
707 |
250
| tagSpacer = lookup("spacer");
|
708 |
250
| tagLayer = lookup("layer");
|
709 |
250
| tagCenter = lookup("center");
|
710 |
250
| tagStyle = lookup("style");
|
711 |
250
| tagScript = lookup("script");
|
712 |
250
| tagNoscript = lookup("noscript");
|
713 |
250
| tagTable = lookup("table");
|
714 |
250
| tagCaption = lookup("caption");
|
715 |
250
| tagForm = lookup("form");
|
716 |
250
| tagTextarea = lookup("textarea");
|
717 |
250
| tagBlockquote = lookup("blockquote");
|
718 |
250
| tagApplet = lookup("applet");
|
719 |
250
| tagObject = lookup("object");
|
720 |
250
| tagDiv = lookup("div");
|
721 |
250
| tagSpan = lookup("span");
|
722 |
250
| tagInput = lookup("input");
|
723 |
250
| tagQ = lookup("q");
|
724 |
250
| tagBlink = lookup("blink");
|
725 |
| } |
726 |
| |
727 |
| |
728 |
| |
729 |
| |
730 |
| |
731 |
247
| public void setConfiguration(Configuration configuration)
|
732 |
| { |
733 |
247
| this.configuration = configuration;
|
734 |
| } |
735 |
| |
736 |
| |
737 |
| |
738 |
| |
739 |
| |
740 |
| |
741 |
29264
| public Dict lookup(String name)
|
742 |
| { |
743 |
29264
| return (Dict) tagHashtable.get(name);
|
744 |
| } |
745 |
| |
746 |
| |
747 |
| |
748 |
| |
749 |
| |
750 |
| |
751 |
30281
| public Dict install(Dict dict)
|
752 |
| { |
753 |
30281
| Dict d = (Dict) tagHashtable.get(dict.name);
|
754 |
30281
| if (d != null)
|
755 |
| { |
756 |
502
| d.versions = dict.versions;
|
757 |
502
| d.model |= dict.model;
|
758 |
502
| d.setParser(dict.getParser());
|
759 |
502
| d.setChkattrs(dict.getChkattrs());
|
760 |
502
| return d;
|
761 |
| } |
762 |
| |
763 |
29779
| tagHashtable.put(dict.name, dict);
|
764 |
29779
| return dict;
|
765 |
| |
766 |
| } |
767 |
| |
768 |
| |
769 |
| |
770 |
| |
771 |
| |
772 |
| |
773 |
13251
| public boolean findTag(Node node)
|
774 |
| { |
775 |
13251
| Dict np;
|
776 |
| |
777 |
13251
| if (configuration != null && configuration.xmlTags)
|
778 |
| { |
779 |
68
| node.tag = XML_TAGS;
|
780 |
68
| return true;
|
781 |
| } |
782 |
| |
783 |
13183
| if (node.element != null)
|
784 |
| { |
785 |
13183
| np = lookup(node.element);
|
786 |
13183
| if (np != null)
|
787 |
| { |
788 |
13134
| node.tag = np;
|
789 |
13134
| return true;
|
790 |
| } |
791 |
| } |
792 |
| |
793 |
49
| return false;
|
794 |
| } |
795 |
| |
796 |
| |
797 |
| |
798 |
| |
799 |
| |
800 |
| |
801 |
81
| public Parser findParser(Node node)
|
802 |
| { |
803 |
81
| Dict np;
|
804 |
| |
805 |
81
| if (node.element != null)
|
806 |
| { |
807 |
81
| np = lookup(node.element);
|
808 |
81
| if (np != null)
|
809 |
| { |
810 |
41
| return np.getParser();
|
811 |
| } |
812 |
| } |
813 |
| |
814 |
40
| return null;
|
815 |
| } |
816 |
| |
817 |
| |
818 |
| |
819 |
| |
820 |
| |
821 |
| |
822 |
229
| boolean isAnchorElement(Node node)
|
823 |
| { |
824 |
229
| return node.tag == this.tagA
|
825 |
| || node.tag == this.tagApplet |
826 |
| || node.tag == this.tagForm |
827 |
| || node.tag == this.tagFrame |
828 |
| || node.tag == this.tagIframe |
829 |
| || node.tag == this.tagImg |
830 |
| || node.tag == this.tagMap; |
831 |
| } |
832 |
| |
833 |
| |
834 |
| |
835 |
| |
836 |
| |
837 |
| |
838 |
31
| public void defineTag(short tagType, String name)
|
839 |
| { |
840 |
31
| Parser tagParser;
|
841 |
31
| short model;
|
842 |
| |
843 |
31
| switch (tagType)
|
844 |
| { |
845 |
2
| case Dict.TAGTYPE_BLOCK :
|
846 |
2
| model = (short) (Dict.CM_BLOCK | Dict.CM_NO_INDENT | Dict.CM_NEW);
|
847 |
2
| tagParser = ParserImpl.BLOCK;
|
848 |
2
| break;
|
849 |
| |
850 |
1
| case Dict.TAGTYPE_EMPTY :
|
851 |
1
| model = (short) (Dict.CM_EMPTY | Dict.CM_NO_INDENT | Dict.CM_NEW);
|
852 |
1
| tagParser = ParserImpl.BLOCK;
|
853 |
1
| break;
|
854 |
| |
855 |
2
| case Dict.TAGTYPE_PRE :
|
856 |
2
| model = (short) (Dict.CM_BLOCK | Dict.CM_NO_INDENT | Dict.CM_NEW);
|
857 |
2
| tagParser = ParserImpl.PRE;
|
858 |
2
| break;
|
859 |
| |
860 |
26
| case Dict.TAGTYPE_INLINE :
|
861 |
0
| default :
|
862 |
| |
863 |
26
| model = (short) (Dict.CM_INLINE | Dict.CM_NO_INDENT | Dict.CM_NEW);
|
864 |
26
| tagParser = ParserImpl.INLINE;
|
865 |
26
| break;
|
866 |
| } |
867 |
| |
868 |
31
| install(new Dict(name, Dict.VERS_PROPRIETARY, model, tagParser, null));
|
869 |
| } |
870 |
| |
871 |
| |
872 |
| |
873 |
| |
874 |
| |
875 |
| |
876 |
4
| List findAllDefinedTag(short tagType)
|
877 |
| { |
878 |
4
| List tagNames = new ArrayList();
|
879 |
| |
880 |
4
| Iterator iterator = tagHashtable.values().iterator();
|
881 |
4
| while (iterator.hasNext())
|
882 |
| { |
883 |
484
| Dict curDictEntry = (Dict) iterator.next();
|
884 |
| |
885 |
484
| if (curDictEntry != null)
|
886 |
| { |
887 |
484
| switch (tagType)
|
888 |
| { |
889 |
| |
890 |
121
| case Dict.TAGTYPE_EMPTY :
|
891 |
121
| if ((curDictEntry.versions == Dict.VERS_PROPRIETARY)
|
892 |
| && ((curDictEntry.model & Dict.CM_EMPTY) == Dict.CM_EMPTY) |
893 |
| && |
894 |
| (curDictEntry != tagWbr)) |
895 |
| { |
896 |
0
| tagNames.add(curDictEntry.name);
|
897 |
| } |
898 |
121
| break;
|
899 |
| |
900 |
| |
901 |
121
| case Dict.TAGTYPE_INLINE :
|
902 |
121
| if ((curDictEntry.versions == Dict.VERS_PROPRIETARY)
|
903 |
| && ((curDictEntry.model & Dict.CM_INLINE) == Dict.CM_INLINE) |
904 |
| && |
905 |
| (curDictEntry != tagBlink) |
906 |
| && (curDictEntry != tagNobr) |
907 |
| && (curDictEntry != tagWbr)) |
908 |
| { |
909 |
2
| tagNames.add(curDictEntry.name);
|
910 |
| } |
911 |
121
| break;
|
912 |
| |
913 |
| |
914 |
121
| case Dict.TAGTYPE_BLOCK :
|
915 |
121
| if ((curDictEntry.versions == Dict.VERS_PROPRIETARY)
|
916 |
| && ((curDictEntry.model & Dict.CM_BLOCK) == Dict.CM_BLOCK) |
917 |
| && (curDictEntry.getParser() == ParserImpl.BLOCK)) |
918 |
| { |
919 |
0
| tagNames.add(curDictEntry.name);
|
920 |
| } |
921 |
121
| break;
|
922 |
| |
923 |
121
| case Dict.TAGTYPE_PRE :
|
924 |
121
| if ((curDictEntry.versions == Dict.VERS_PROPRIETARY)
|
925 |
| && ((curDictEntry.model & Dict.CM_BLOCK) == Dict.CM_BLOCK) |
926 |
| && (curDictEntry.getParser() == ParserImpl.PRE)) |
927 |
| { |
928 |
0
| tagNames.add(curDictEntry.name);
|
929 |
| } |
930 |
121
| break;
|
931 |
| } |
932 |
| } |
933 |
| } |
934 |
| |
935 |
4
| return tagNames;
|
936 |
| } |
937 |
| |
938 |
| |
939 |
| |
940 |
| |
941 |
| |
942 |
6
| public void freeAttrs(Node node)
|
943 |
| { |
944 |
6
| while (node.attributes != null)
|
945 |
| { |
946 |
23
| AttVal av = node.attributes;
|
947 |
23
| if ("id".equalsIgnoreCase(av.attribute) || "name".equalsIgnoreCase(av.attribute) && isAnchorElement(node))
|
948 |
| { |
949 |
0
| removeAnchorByNode(node);
|
950 |
| } |
951 |
| |
952 |
23
| node.attributes = av.next;
|
953 |
| } |
954 |
| } |
955 |
| |
956 |
| |
957 |
| |
958 |
| |
959 |
| |
960 |
0
| void removeAnchorByNode(Node node)
|
961 |
| { |
962 |
0
| Anchor delme = null;
|
963 |
0
| Anchor found = null;
|
964 |
0
| Anchor prev = null;
|
965 |
0
| Anchor next = null;
|
966 |
| |
967 |
0
| for (found = anchorList; found != null; found = found.next)
|
968 |
| { |
969 |
0
| next = found.next;
|
970 |
| |
971 |
0
| if (found.node == node)
|
972 |
| { |
973 |
0
| if (prev != null)
|
974 |
| { |
975 |
0
| prev.next = next;
|
976 |
| } |
977 |
| else |
978 |
| { |
979 |
0
| anchorList = next;
|
980 |
| } |
981 |
| |
982 |
0
| delme = found;
|
983 |
| } |
984 |
| else |
985 |
| { |
986 |
0
| prev = found;
|
987 |
| } |
988 |
| } |
989 |
0
| if (delme != null)
|
990 |
| { |
991 |
0
| delme = null;
|
992 |
| } |
993 |
| } |
994 |
| |
995 |
| |
996 |
| |
997 |
| |
998 |
| |
999 |
122
| Anchor newAnchor()
|
1000 |
| { |
1001 |
122
| Anchor a = new Anchor();
|
1002 |
122
| return a;
|
1003 |
| } |
1004 |
| |
1005 |
| |
1006 |
| |
1007 |
| |
1008 |
| |
1009 |
| |
1010 |
| |
1011 |
122
| Anchor addAnchor(String name, Node node)
|
1012 |
| { |
1013 |
122
| Anchor a = newAnchor();
|
1014 |
| |
1015 |
122
| a.name = name;
|
1016 |
122
| a.node = node;
|
1017 |
| |
1018 |
122
| if (anchorList == null)
|
1019 |
| { |
1020 |
23
| anchorList = a;
|
1021 |
| } |
1022 |
| else |
1023 |
| { |
1024 |
99
| Anchor here = anchorList;
|
1025 |
| |
1026 |
99
| while (here.next != null)
|
1027 |
| { |
1028 |
1248
| here = here.next;
|
1029 |
| } |
1030 |
99
| here.next = a;
|
1031 |
| } |
1032 |
| |
1033 |
122
| return anchorList;
|
1034 |
| } |
1035 |
| |
1036 |
| |
1037 |
| |
1038 |
| |
1039 |
| |
1040 |
| |
1041 |
141
| Node getNodeByAnchor(String name)
|
1042 |
| { |
1043 |
141
| Anchor found;
|
1044 |
| |
1045 |
141
| for (found = anchorList; found != null; found = found.next)
|
1046 |
| { |
1047 |
1499
| if (name.equalsIgnoreCase(found.name))
|
1048 |
| { |
1049 |
21
| break;
|
1050 |
| } |
1051 |
| } |
1052 |
| |
1053 |
141
| if (found != null)
|
1054 |
| { |
1055 |
21
| return found.node;
|
1056 |
| } |
1057 |
| |
1058 |
120
| return null;
|
1059 |
| } |
1060 |
| |
1061 |
| |
1062 |
| |
1063 |
| |
1064 |
0
| void freeAnchors()
|
1065 |
| { |
1066 |
0
| anchorList = null;
|
1067 |
| } |
1068 |
| |
1069 |
| } |