001: package it.unimi.dsi.mg4j.util.parser;
002:
003: /*
004: * MG4J: Managing Gigabytes for Java
005: *
006: * Copyright (C) 2005-2007 Sebastiano Vigna
007: *
008: * This library is free software; you can redistribute it and/or modify it
009: * under the terms of the GNU Lesser General Public License as published by the Free
010: * Software Foundation; either version 2.1 of the License, or (at your option)
011: * any later version.
012: *
013: * This library is distributed in the hope that it will be useful, but
014: * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
015: * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
016: * for more details.
017: *
018: * You should have received a copy of the GNU Lesser General Public License
019: * along with this program; if not, write to the Free Software
020: * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
021: *
022: */
023:
024: import it.unimi.dsi.fastutil.Hash;
025: import it.unimi.dsi.fastutil.objects.ReferenceLinkedOpenHashSet;
026: import it.unimi.dsi.lang.MutableString;
027:
028: /** An HTML element type.
029: * @deprecated Moved to <code>dsiutils</code>.
030: */
031: @Deprecated
032: public final class Element {
033:
034: /** The name of the type of this element. */
035: public final CharSequence name;
036: /** The length of {@link #name}. */
037: public final int nameLength;
038: /** Whether this element breaks the flow. */
039: public final boolean breaksFlow;
040: /** Whether this element is simple. */
041: public final boolean isSimple;
042: /** Whether this element has implicit closure. */
043: public final boolean isImplicit;
044: /** The content model for this element. */
045: final ReferenceLinkedOpenHashSet<Element> contentModel;
046:
047: /** Creates a new element with the specified name.
048: * The element is assumed to break the flow,
049: * and neither being simple nor having implicit closure.
050: *
051: * @param name the name of the type of the new element.
052: */
053: public Element(final CharSequence name) {
054: this (name, true, false, false);
055: }
056:
057: /** Creates a new element with the specified name and flags.
058: * The element is assumed not to have implicit closure.
059: *
060: * @param name the name of the type of the new element.
061: * @param breaksFlow true if this elements breaks the flow.
062: * @param isSimple true if this element is simple.
063: */
064: public Element(final CharSequence name, final boolean breaksFlow,
065: final boolean isSimple) {
066: this (name, breaksFlow, isSimple, false);
067: }
068:
069: /** Creates a new element.
070: *
071: * @param name the name of the type of the new element.
072: * @param breaksFlow true if this elements breaks the flow.
073: * @param isSimple true if this element is simple.
074: * @param isImplicit true if this element has implicit closure.
075: */
076: public Element(final CharSequence name, final boolean breaksFlow,
077: final boolean isSimple, final boolean isImplicit) {
078: this .name = new MutableString(name);
079: this .nameLength = name.length();
080: this .breaksFlow = breaksFlow;
081: this .isSimple = isSimple;
082: this .isImplicit = isImplicit;
083: this .contentModel = new ReferenceLinkedOpenHashSet<Element>(
084: Hash.DEFAULT_INITIAL_SIZE, .5f);
085: }
086:
087: /** Returns the name of this element.
088: * @return the name of this element.
089: */
090: public String toString() {
091: return name.toString();
092: }
093:
094: /* --- Tag Names ----------------------------------- */
095: public static final Element A = HTMLFactory.newElement("a");
096: public static final Element ABBR = HTMLFactory.newElement("abbr");
097: public static final Element ACRONYM = HTMLFactory
098: .newElement("acronym");
099: public static final Element ADDRESS = HTMLFactory
100: .newElement("address");
101: // deprecated
102: public static final Element APPLET = HTMLFactory
103: .newElement("applet");
104: // forbidden
105: public static final Element AREA = HTMLFactory.newElement("area",
106: true, true);
107: // flowMaintainer
108: public static final Element B = HTMLFactory.newElement("b", false,
109: false);
110: // forbidden
111: public static final Element BASE = HTMLFactory.newElement("base",
112: true, true, false);
113: // flowMaintainer, forbidden, deprecated
114: public static final Element BASEFONT = HTMLFactory.newElement(
115: "basefont", false, true);
116: public static final Element BDO = HTMLFactory.newElement("bdo");
117: // flowMaintainer
118: public static final Element BIG = HTMLFactory.newElement("big",
119: false, false);
120: public static final Element BLOCKQUOTE = HTMLFactory
121: .newElement("blockquote");
122: // 2optional --- even opening is optiona
123: public static final Element BODY = HTMLFactory.newElement("body",
124: true, false, true);
125: // forbidden
126: public static final Element BR = HTMLFactory.newElement("br", true,
127: true);
128: public static final Element BUTTON = HTMLFactory
129: .newElement("button");
130: public static final Element CAPTION = HTMLFactory
131: .newElement("caption");
132: /*Deprecated*/public static final Element CENTER = HTMLFactory
133: .newElement("center");
134: public static final Element CITE = HTMLFactory.newElement("cite");
135: // flowMaintainer
136: public static final Element CODE = HTMLFactory.newElement("code",
137: false, false);
138: // forbidden
139: public static final Element COL = HTMLFactory.newElement("col",
140: true, true);
141: // optional
142: public static final Element COLGROUP = HTMLFactory.newElement(
143: "colgroup", true, false, true);
144: // optional
145: public static final Element DD = HTMLFactory.newElement("dd", true,
146: false, true);
147: public static final Element DEL = HTMLFactory.newElement("del");
148: public static final Element DFN = HTMLFactory.newElement("dfn");
149: /*Deprecated*/public static final Element DIR = HTMLFactory
150: .newElement("dir");
151: public static final Element DIV = HTMLFactory.newElement("div");
152: public static final Element DL = HTMLFactory.newElement("dl");
153: // optional
154: public static final Element DT = HTMLFactory.newElement("dt", true,
155: false, true);
156: // flowMaintainer
157: public static final Element EM = HTMLFactory.newElement("em",
158: false, false);
159: // Nonstandard
160: public static final Element EMBED = HTMLFactory.newElement("embed",
161: false, false);
162: public static final Element FIELDSET = HTMLFactory
163: .newElement("fieldset");
164: // flowMaintainer
165: /*Deprecated*/public static final Element FONT = HTMLFactory
166: .newElement("font", false, false);
167: public static final Element FORM = HTMLFactory.newElement("form");
168: // forbidden
169: public static final Element FRAME = HTMLFactory.newElement("frame",
170: true, true);
171: public static final Element FRAMESET = HTMLFactory
172: .newElement("frameset");
173: public static final Element H1 = HTMLFactory.newElement("h1");
174: public static final Element H2 = HTMLFactory.newElement("h2");
175: public static final Element H3 = HTMLFactory.newElement("h3");
176: public static final Element H4 = HTMLFactory.newElement("h4");
177: public static final Element H5 = HTMLFactory.newElement("h5");
178: public static final Element H6 = HTMLFactory.newElement("h6");
179: // 2optional --- even opening is optional
180: public static final Element HEAD = HTMLFactory.newElement("head",
181: true, false, true);
182: // forbidden
183: public static final Element HR = HTMLFactory.newElement("hr", true,
184: true);
185: // 2optional --- even opening is optional
186: public static final Element HTML = HTMLFactory.newElement("html",
187: true, false, true);
188: // flowMaintainer
189: public static final Element I = HTMLFactory.newElement("i", false,
190: false);
191: public static final Element IFRAME = HTMLFactory
192: .newElement("iframe");
193: // flowMaintainer, forbidden
194: public static final Element IMG = HTMLFactory.newElement("img",
195: false, true);
196: // forbidden
197: public static final Element INPUT = HTMLFactory.newElement("input",
198: true, true);
199: public static final Element INS = HTMLFactory.newElement("ins");
200: // forbidden, deprecated
201: public static final Element ISINDEX = HTMLFactory.newElement(
202: "isindex", true, true);
203: public static final Element KBD = HTMLFactory.newElement("kbd");
204: public static final Element LABEL = HTMLFactory.newElement("label");
205: public static final Element LEGEND = HTMLFactory
206: .newElement("legend");
207: // optional
208: public static final Element LI = HTMLFactory.newElement("li", true,
209: false, true);
210: // forbidden
211: public static final Element LINK = HTMLFactory.newElement("link",
212: true, true);
213: public static final Element MAP = HTMLFactory.newElement("map");
214: public static final Element MENU = HTMLFactory.newElement("menu");
215: // forbidden
216: public static final Element META = HTMLFactory.newElement("meta",
217: true, true);
218: public static final Element NOFRAMES = HTMLFactory
219: .newElement("noframes");
220: public static final Element NOSCRIPT = HTMLFactory
221: .newElement("noscript");
222: public static final Element OBJECT = HTMLFactory
223: .newElement("object");
224: public static final Element OL = HTMLFactory.newElement("ol");
225: // optional
226: public static final Element OPTION = HTMLFactory.newElement(
227: "option", true, false, true);
228: public static final Element OPTGROUP = HTMLFactory
229: .newElement("optgroup");
230: // optional
231: public static final Element P = HTMLFactory.newElement("p", true,
232: false, true);
233: // forbidden
234: public static final Element PARAM = HTMLFactory.newElement("param",
235: true, true);
236: public static final Element PRE = HTMLFactory.newElement("pre");
237: public static final Element Q = HTMLFactory.newElement("q");
238: // flowMaintainer
239: public static final Element SAMP = HTMLFactory.newElement("samp",
240: false, false);
241: public static final Element SCRIPT = HTMLFactory
242: .newElement("script");
243: public static final Element SELECT = HTMLFactory
244: .newElement("select");
245: // flowMaintainer
246: public static final Element SMALL = HTMLFactory.newElement("small",
247: false, false);
248: // flowMaintainer
249: public static final Element SPAN = HTMLFactory.newElement("span",
250: false, false);
251: // flowMaintainer, deprecated
252: public static final Element STRIKE = HTMLFactory.newElement(
253: "strike", false, false);
254: // flowMaintainer, deprecated
255: public static final Element S = HTMLFactory.newElement("s", false,
256: false);
257: // flowMaintainer
258: public static final Element STRONG = HTMLFactory.newElement(
259: "strong", false, false);
260: public static final Element STYLE = HTMLFactory.newElement("style");
261: public static final Element SUB = HTMLFactory.newElement("sub");
262: public static final Element SUP = HTMLFactory.newElement("sup");
263: public static final Element TABLE = HTMLFactory.newElement("table");
264: // 2optional --- even opening is optional
265: public static final Element TBODY = HTMLFactory.newElement("tbody",
266: true, false, true);
267: // optional
268: public static final Element TD = HTMLFactory.newElement("td", true,
269: false, true);
270: public static final Element TEXTAREA = HTMLFactory
271: .newElement("textarea");
272: // optional
273: public static final Element TFOOT = HTMLFactory.newElement("tfoot",
274: true, false, true);
275: // optional
276: public static final Element TH = HTMLFactory.newElement("th", true,
277: false, true);
278: // optional
279: public static final Element THEAD = HTMLFactory.newElement("thead",
280: true, false, true);
281: public static final Element TITLE = HTMLFactory.newElement("title");
282: // optional
283: public static final Element TR = HTMLFactory.newElement("tr", true,
284: false, true);
285: // flowMaintainer
286: public static final Element TT = HTMLFactory.newElement("tt",
287: false, false);
288: // flowMaintainer, deprecated
289: public static final Element U = HTMLFactory.newElement("u", false,
290: false);
291: public static final Element UL = HTMLFactory.newElement("ul");
292: public static final Element VAR = HTMLFactory.newElement("var");
293: public static final Element UNKNOWN = HTMLFactory
294: .newElement("unknown");
295:
296: private static final ReferenceLinkedOpenHashSet<Element> HEADING = new ReferenceLinkedOpenHashSet<Element>(
297: Hash.DEFAULT_INITIAL_SIZE, .5f);
298: private static final ReferenceLinkedOpenHashSet<Element> LIST = new ReferenceLinkedOpenHashSet<Element>(
299: Hash.DEFAULT_INITIAL_SIZE, .5f);
300: private static final ReferenceLinkedOpenHashSet<Element> PREFORMATTED = new ReferenceLinkedOpenHashSet<Element>(
301: Hash.DEFAULT_INITIAL_SIZE, .5f);
302: private static final ReferenceLinkedOpenHashSet<Element> FONTSTYLE = new ReferenceLinkedOpenHashSet<Element>(
303: Hash.DEFAULT_INITIAL_SIZE, .5f);
304: private static final ReferenceLinkedOpenHashSet<Element> PHRASE = new ReferenceLinkedOpenHashSet<Element>(
305: Hash.DEFAULT_INITIAL_SIZE, .5f);
306: private static final ReferenceLinkedOpenHashSet<Element> SPECIAL = new ReferenceLinkedOpenHashSet<Element>(
307: Hash.DEFAULT_INITIAL_SIZE, .5f);
308: private static final ReferenceLinkedOpenHashSet<Element> FORM_CONTROL = new ReferenceLinkedOpenHashSet<Element>(
309: Hash.DEFAULT_INITIAL_SIZE, .5f);
310: private static final ReferenceLinkedOpenHashSet<Element> INLINE = new ReferenceLinkedOpenHashSet<Element>(
311: Hash.DEFAULT_INITIAL_SIZE, .5f);
312: private static final ReferenceLinkedOpenHashSet<Element> BLOCK = new ReferenceLinkedOpenHashSet<Element>(
313: Hash.DEFAULT_INITIAL_SIZE, .5f);
314: private static final ReferenceLinkedOpenHashSet<Element> FLOW = new ReferenceLinkedOpenHashSet<Element>(
315: Hash.DEFAULT_INITIAL_SIZE, .5f);
316: private static final ReferenceLinkedOpenHashSet<Element> PRE_EXCLUSION = new ReferenceLinkedOpenHashSet<Element>(
317: Hash.DEFAULT_INITIAL_SIZE, .5f);
318:
319: static {
320: // We define sets for several entities contained in the HTML 4.01 loose DTD (http://www.w3.org/TR/html4/loose.dtd).
321:
322: /* <!ENTITY % heading "H1|H2|H3|H4|H5|H6">*/
323: HEADING.add(Element.H1);
324: HEADING.add(Element.H2);
325: HEADING.add(Element.H3);
326: HEADING.add(Element.H4);
327: HEADING.add(Element.H5);
328: HEADING.add(Element.H6);
329:
330: /* <!ENTITY % list "UL | OL | DIR | MENU"> */
331: LIST.add(Element.UL);
332: LIST.add(Element.OL);
333: LIST.add(Element.DIR);
334: LIST.add(Element.MENU);
335:
336: /* <!ENTITY % preformatted "PRE"> */
337: PREFORMATTED.add(Element.PRE);
338:
339: /*<!ENTITY % fontstyle "TT | I | B | U | S | STRIKE | BIG | SMALL"> */
340: FONTSTYLE.add(Element.TT);
341: FONTSTYLE.add(Element.I);
342: FONTSTYLE.add(Element.B);
343: FONTSTYLE.add(Element.U);
344: FONTSTYLE.add(Element.S);
345: FONTSTYLE.add(Element.STRIKE);
346: FONTSTYLE.add(Element.BIG);
347: FONTSTYLE.add(Element.SMALL);
348:
349: /* <!ENTITY % phrase "EM | STRONG | DFN | CODE | SAMP | KBD | VAR | CITE | ABBR | ACRONYM" > */
350: PHRASE.add(Element.EM);
351: PHRASE.add(Element.STRONG);
352: PHRASE.add(Element.SAMP);
353: PHRASE.add(Element.CODE);
354: PHRASE.add(Element.KBD);
355: PHRASE.add(Element.DFN);
356: PHRASE.add(Element.VAR);
357: PHRASE.add(Element.CITE);
358: PHRASE.add(Element.ABBR);
359: PHRASE.add(Element.ACRONYM);
360:
361: /* <!ENTITY % special "A | IMG | APPLET | OBJECT | FONT | BASEFONT | BR | SCRIPT |
362: MAP | Q | SUB | SUP | SPAN | BDO | IFRAME"> */
363: SPECIAL.add(Element.A);
364: SPECIAL.add(Element.SPAN);
365: SPECIAL.add(Element.FONT);
366: SPECIAL.add(Element.IMG);
367: SPECIAL.add(Element.APPLET);
368: SPECIAL.add(Element.OBJECT);
369: SPECIAL.add(Element.BASEFONT);
370: SPECIAL.add(Element.BR);
371: SPECIAL.add(Element.EMBED);
372: SPECIAL.add(Element.SCRIPT);
373: SPECIAL.add(Element.MAP);
374: SPECIAL.add(Element.Q);
375: SPECIAL.add(Element.SUB);
376: SPECIAL.add(Element.SUP);
377: SPECIAL.add(Element.BDO);
378: SPECIAL.add(Element.IFRAME);
379:
380: /* <!ENTITY % formctrl "INPUT | SELECT | TEXTAREA | LABEL | BUTTON"> */
381: FORM_CONTROL.add(Element.INPUT);
382: FORM_CONTROL.add(Element.SELECT);
383: FORM_CONTROL.add(Element.TEXTAREA);
384: FORM_CONTROL.add(Element.LABEL);
385: FORM_CONTROL.add(Element.BUTTON);
386:
387: /* <!ENTITY % inline "#PCDATA | %fontstyle; | %phrase; | %special; | %formctrl;"> */
388: INLINE.addAll(PHRASE);
389: INLINE.addAll(FONTSTYLE);
390: INLINE.addAll(SPECIAL);
391: INLINE.addAll(FORM_CONTROL);
392:
393: /* <!ENTITY % block "P | %heading; | %list; | %preformatted; | DL | DIV | CENTER |
394: NOSCRIPT | NOFRAMES | BLOCKQUOTE | FORM | ISINDEX | HR | TABLE | FIELDSET | ADDRESS"> */
395: BLOCK.add(Element.P);
396: BLOCK.add(Element.DIV);
397: BLOCK.add(Element.TABLE);
398: BLOCK.add(Element.FORM);
399: BLOCK.add(Element.DL);
400: BLOCK.add(Element.BLOCKQUOTE);
401: BLOCK.add(Element.CENTER);
402: BLOCK.add(Element.NOSCRIPT);
403: BLOCK.add(Element.NOFRAMES);
404: BLOCK.add(Element.ISINDEX);
405: BLOCK.add(Element.HR);
406: BLOCK.add(Element.FIELDSET);
407: BLOCK.add(Element.ADDRESS);
408: BLOCK.addAll(HEADING);
409: BLOCK.addAll(LIST);
410: BLOCK.addAll(PREFORMATTED);
411:
412: /* <!ENTITY % flow "%block; | %inline;"> */
413: FLOW.addAll(INLINE);
414: FLOW.addAll(BLOCK);
415:
416: /* <!ENTITY % pre.exclusion "IMG|OBJECT|APPLET|BIG|SMALL|SUB|SUP|FONT|BASEFONT"> */
417: PRE_EXCLUSION.add(Element.IMG);
418: PRE_EXCLUSION.add(Element.OBJECT);
419: PRE_EXCLUSION.add(Element.APPLET);
420: PRE_EXCLUSION.add(Element.BIG);
421: PRE_EXCLUSION.add(Element.SMALL);
422: PRE_EXCLUSION.add(Element.SUB);
423: PRE_EXCLUSION.add(Element.SUP);
424: PRE_EXCLUSION.add(Element.FONT);
425: PRE_EXCLUSION.add(Element.BASEFONT);
426: }
427:
428: static {
429: /* <!ENTITY % fontstyle "TT | I | B | U | S | STRIKE | BIG | SMALL">
430: <!ENTITY % phrase "EM | STRONG | DFN | CODE | SAMP | KBD | VAR | CITE | ABBR | ACRONYM" >
431: <!ELEMENT (%fontstyle;|%phrase;) - - (%inline;)*> */
432: Element.ACRONYM.contentModel.addAll(INLINE);
433: Element.ABBR.contentModel.addAll(INLINE);
434: Element.CITE.contentModel.addAll(INLINE);
435: Element.VAR.contentModel.addAll(INLINE);
436: Element.KBD.contentModel.addAll(INLINE);
437: Element.SAMP.contentModel.addAll(INLINE);
438: Element.CODE.contentModel.addAll(INLINE);
439: Element.DFN.contentModel.addAll(INLINE);
440: Element.STRONG.contentModel.addAll(INLINE);
441: Element.EM.contentModel.addAll(INLINE);
442: Element.SMALL.contentModel.addAll(INLINE);
443: Element.BIG.contentModel.addAll(INLINE);
444: Element.STRIKE.contentModel.addAll(INLINE);
445: Element.S.contentModel.addAll(INLINE);
446: Element.U.contentModel.addAll(INLINE);
447: Element.B.contentModel.addAll(INLINE);
448: Element.I.contentModel.addAll(INLINE);
449: Element.TT.contentModel.addAll(INLINE);
450:
451: /* <!ELEMENT (SUB|SUP) - - (%inline;)* -- subscript, superscript --> */
452: Element.SUB.contentModel.addAll(INLINE);
453: Element.SUP.contentModel.addAll(INLINE);
454:
455: /* <!ELEMENT SPAN - - (%inline;)* -- generic language/style container --> */
456: Element.SPAN.contentModel.addAll(INLINE);
457:
458: /* <!ELEMENT BDO - - (%inline;)* -- I18N BiDi over-ride --> */
459: Element.BDO.contentModel.addAll(INLINE);
460:
461: /* <!ELEMENT BASEFONT - O EMPTY -- base font size --> */
462: // The map is created empty
463: /* <!ELEMENT FONT - - (%inline;)* -- local change to font --> */
464: Element.FONT.contentModel.addAll(INLINE);
465:
466: /* <!ELEMENT BR - O EMPTY -- forced line break --> */
467: // The map is created empty
468: /* <!ELEMENT BODY O O (%flow;)* +(INS|DEL)-- document body --> */
469: Element.BODY.contentModel.addAll(FLOW);
470: Element.BODY.contentModel.add(Element.INS);
471: Element.BODY.contentModel.add(Element.DEL);
472:
473: /* <!ELEMENT ADDRESS - - ((%inline;)|P)* -- information on author --> */
474: Element.ADDRESS.contentModel.addAll(INLINE);
475: Element.ADDRESS.contentModel.add(Element.P);
476:
477: /* <!ELEMENT DIV - - (%flow;)* -- generic language/style container --> */
478: Element.DIV.contentModel.addAll(FLOW);
479:
480: /* <!ELEMENT CENTER - - (%flow;)* -- shorthand for DIV align=center --> */
481: Element.CENTER.contentModel.addAll(FLOW);
482:
483: /* <!ELEMENT A - - (%inline;)* -(A) -- anchor --> */
484: Element.A.contentModel.addAll(INLINE);
485: Element.A.contentModel.remove(Element.A);
486: Element.A.contentModel.rehash();
487:
488: /* <!ELEMENT MAP - - ((%block;) | AREA)+ -- client-side image map --> */
489: Element.MAP.contentModel.addAll(BLOCK);
490: Element.MAP.contentModel.add(Element.AREA);
491:
492: /* <!ELEMENT AREA - O EMPTY -- client-side image map area --> */
493: // The map is created empty
494: /* <!ELEMENT LINK - O EMPTY -- a media-independent link --> */
495: // The map is created empty
496: /* <!ELEMENT IMG - O EMPTY -- Embedded image --> */
497: // The map is created empty
498: /* <!ELEMENT OBJECT - - (PARAM | %flow;)* -- generic embedded object --> */
499: Element.OBJECT.contentModel.add(Element.PARAM);
500: Element.OBJECT.contentModel.addAll(FLOW);
501:
502: /* <!ELEMENT PARAM - O EMPTY -- named property value --> */
503: // The map is created empty
504: /* <!ELEMENT APPLET - - (PARAM | %flow;)* -- Java applet --> */
505: Element.APPLET.contentModel.add(Element.PARAM);
506: Element.APPLET.contentModel.addAll(FLOW);
507:
508: /* <!ELEMENT HR - O EMPTY -- horizontal rule --> */
509: // The map is created empty
510: /* <!ELEMENT P - O (%inline;)* -- paragraph --> */
511: Element.P.contentModel.addAll(INLINE);
512:
513: /* <!ELEMENT (%heading;) - - (%inline;)* -- heading --> */
514: /* <!ENTITY % heading "H1|H2|H3|H4|H5|H6">*/
515: Element.H6.contentModel.addAll(INLINE);
516: Element.H5.contentModel.addAll(INLINE);
517: Element.H4.contentModel.addAll(INLINE);
518: Element.H3.contentModel.addAll(INLINE);
519: Element.H2.contentModel.addAll(INLINE);
520: Element.H1.contentModel.addAll(INLINE);
521:
522: /* <!ELEMENT PRE - - (%inline;)* -(%pre.exclusion;) -- preformatted text --> */
523: Element.PRE.contentModel.addAll(INLINE);
524: Element.PRE.contentModel.removeAll(PRE_EXCLUSION);
525: Element.PRE.contentModel.rehash();
526:
527: /* <!ELEMENT Q - - (%inline;)* -- short inline quotation --> */
528: Element.Q.contentModel.addAll(INLINE);
529:
530: /* <!ELEMENT BLOCKQUOTE - - (%flow;)* -- long quotation --> */
531: Element.BLOCKQUOTE.contentModel.addAll(FLOW);
532:
533: /* <!ELEMENT (INS|DEL) - - (%flow;)* -- inserted text, deleted text --> */
534: Element.INS.contentModel.addAll(FLOW);
535: Element.DEL.contentModel.addAll(FLOW);
536:
537: /* <!ELEMENT DL - - (DT|DD)+ -- definition list --> */
538: Element.DL.contentModel.add(Element.DT);
539: Element.DL.contentModel.add(Element.DD);
540:
541: /* <!ELEMENT DT - O (%inline;)* -- definition term --> */
542: Element.DT.contentModel.addAll(INLINE);
543:
544: /* <!ELEMENT DD - O (%flow;)* -- definition description --> */
545: Element.DD.contentModel.addAll(FLOW);
546:
547: /* <!ELEMENT OL - - (LI)+ -- ordered list --> */
548: Element.OL.contentModel.add(Element.LI);
549:
550: /* <!ELEMENT UL - - (LI)+ -- unordered list --> */
551: Element.UL.contentModel.add(Element.LI);
552:
553: /* <!ELEMENT (DIR|MENU) - - (LI)+ -(%block;) -- directory list, menu list --> */
554: Element.DIR.contentModel.add(Element.LI);
555: Element.DIR.contentModel.removeAll(BLOCK);
556: Element.DIR.contentModel.rehash();
557: Element.MENU.contentModel.addAll(Element.DIR.contentModel);
558:
559: /* <!ELEMENT LI - O (%flow;)* -- list item --> */
560: Element.LI.contentModel.addAll(FLOW);
561:
562: /* <!ELEMENT FORM - - (%flow;)* -(FORM) -- interactive form --> */
563: Element.FORM.contentModel.addAll(FLOW);
564: Element.FORM.contentModel.remove(Element.FORM);
565: Element.FORM.contentModel.rehash();
566:
567: /* <!ELEMENT LABEL - - (%inline;)* -(LABEL) -- form field label text --> */
568: Element.LABEL.contentModel.addAll(INLINE);
569: Element.LABEL.contentModel.remove(Element.LABEL);
570: Element.LABEL.contentModel.rehash();
571:
572: /* <!ELEMENT INPUT - O EMPTY -- form control --> */
573: // The map is created empty
574: /* <!ELEMENT SELECT - - (OPTGROUP|OPTION)+ -- option selector --> */
575: Element.SELECT.contentModel.add(Element.OPTION);
576: Element.SELECT.contentModel.add(Element.OPTGROUP);
577:
578: /* <!ELEMENT OPTGROUP - - (OPTION)+ -- option group --> */
579: Element.OPTGROUP.contentModel.add(Element.OPTION);
580:
581: /* <!ELEMENT OPTION - O (#PCDATA) -- selectable choice --> */
582: // The map is created empty
583: /* <!ELEMENT TEXTAREA - - (#PCDATA) -- multi-line text field --> */
584: // The map is created empty
585: /* <!ELEMENT FIELDSET - - (#PCDATA,LEGEND,(%flow;)*) -- form control group --> */
586: Element.FIELDSET.contentModel.addAll(FLOW);
587:
588: /* <!ELEMENT LEGEND - - (%inline;)* -- fieldset legend --> */
589: Element.LEGEND.contentModel.addAll(INLINE);
590:
591: /* <!ELEMENT BUTTON - - (%flow;)* -(A|%formctrl;|FORM|ISINDEX|FIELDSET|IFRAME) -- push button --> */
592: Element.BUTTON.contentModel.addAll(FLOW);
593: Element.BUTTON.contentModel.removeAll(FORM_CONTROL);
594: Element.BUTTON.contentModel.remove(Element.A);
595: Element.BUTTON.contentModel.remove(Element.FORM);
596: Element.BUTTON.contentModel.remove(Element.ISINDEX);
597: Element.BUTTON.contentModel.remove(Element.FIELDSET);
598: Element.BUTTON.contentModel.remove(Element.IFRAME);
599: Element.BUTTON.contentModel.rehash();
600:
601: /* <!ELEMENT TABLE - - (CAPTION?, (COL*|COLGROUP*), THEAD?, TFOOT?, TBODY+)> */
602: Element.TABLE.contentModel.add(Element.TBODY);
603: Element.TABLE.contentModel.add(Element.THEAD);
604: Element.TABLE.contentModel.add(Element.TFOOT);
605: Element.TABLE.contentModel.add(Element.COL);
606: Element.TABLE.contentModel.add(Element.COLGROUP);
607: Element.TABLE.contentModel.add(Element.CAPTION);
608:
609: /* <!ELEMENT CAPTION - - (%inline;)* -- table caption --> */
610: Element.CAPTION.contentModel.addAll(INLINE);
611:
612: /* <!ELEMENT THEAD - O (TR)+ -- table header --> */
613: Element.THEAD.contentModel.add(Element.TR);
614:
615: /* <!ELEMENT TFOOT - O (TR)+ -- table footer --> */
616: Element.TFOOT.contentModel.add(Element.TR);
617:
618: /* <!ELEMENT TBODY O O (TR)+ -- table body --> */
619: Element.TBODY.contentModel.add(Element.TR);
620:
621: /* <!ELEMENT COLGROUP - O (COL)* -- table column group --> */
622: Element.COLGROUP.contentModel.add(Element.COL);
623:
624: /* <!ELEMENT COL - O EMPTY -- table column --> */
625: // The map is created empty
626: /* <!ELEMENT TR - O (TH|TD)+ -- table row --> */
627: Element.TR.contentModel.add(Element.TD);
628: Element.TR.contentModel.add(Element.TH);
629:
630: /* <!ELEMENT (TH|TD) - O (%flow;)* -- table header cell, table data cell--> */
631: Element.TH.contentModel.addAll(FLOW);
632: Element.TD.contentModel.addAll(FLOW);
633:
634: /* <!ELEMENT FRAMESET - - ((FRAMESET|FRAME)+ & NOFRAMES?) -- window subdivision--> */
635: Element.FRAMESET.contentModel.add(Element.FRAME);
636: Element.FRAMESET.contentModel.add(Element.FRAMESET);
637: Element.FRAMESET.contentModel.add(Element.NOFRAMES);
638:
639: /* <!ELEMENT FRAME - O EMPTY -- subwindow --> */
640: // The map is created empty
641: /* <!ELEMENT IFRAME - - (%flow;)* -- inline subwindow --> */
642: Element.IFRAME.contentModel.addAll(FLOW);
643:
644: /* Nonstandard */
645: Element.EMBED.contentModel.addAll(INLINE);
646: Element.EMBED.contentModel.addAll(BLOCK);
647:
648: /* <![ %HTML.Frameset; [<!ENTITY % noframes.content "(BODY) -(NOFRAMES)">]]>
649: <!ENTITY % noframes.content "(%flow;)*">
650: <!ELEMENT NOFRAMES - - %noframes.content; -- alternate content container for non frame-based rendering --> */
651: Element.NOFRAMES.contentModel.addAll(FLOW);
652: Element.NOFRAMES.contentModel.remove(Element.NOFRAMES);
653: Element.NOFRAMES.contentModel.rehash();
654:
655: /* <!-- %head.misc; defined earlier on as "SCRIPT|STYLE|META|LINK|OBJECT" -->
656: <!ENTITY % head.content "TITLE & ISINDEX? & BASE?">
657: <!ELEMENT HEAD O O (%head.content;) +(%head.misc;) -- document head --> */
658: Element.HEAD.contentModel.add(Element.SCRIPT);
659: Element.HEAD.contentModel.add(Element.STYLE);
660: Element.HEAD.contentModel.add(Element.META);
661: Element.HEAD.contentModel.add(Element.LINK);
662: Element.HEAD.contentModel.add(Element.OBJECT);
663: Element.HEAD.contentModel.add(Element.TITLE);
664: Element.HEAD.contentModel.add(Element.ISINDEX);
665: Element.HEAD.contentModel.add(Element.BASE);
666:
667: /* <!ELEMENT TITLE - - (#PCDATA) -(%head.misc;) -- document title --> */
668: // The map is created empty
669: /* <!ELEMENT ISINDEX - O EMPTY -- single line prompt --> */
670: // The map is created empty
671: /* <!ELEMENT BASE - O EMPTY -- document base URI --> */
672: // The map is created empty
673: /* <!ELEMENT META - O EMPTY -- generic metainformation --> */
674: // The map is created empty
675: /* <!ELEMENT STYLE - - %StyleSheet -- style info --> */
676: // The map is created empty
677: /* <!ELEMENT SCRIPT - - %Script; -- script statements --> */
678: // The map is created empty
679: /* <!ELEMENT NOSCRIPT - - (%flow;)* -- alternate content container for non script-based rendering --> */
680: Element.NOSCRIPT.contentModel.addAll(FLOW);
681:
682: /* <![ %HTML.Frameset; [<!ENTITY % html.content "HEAD, FRAMESET">]]>
683: <!ENTITY % html.content "HEAD, BODY">
684: <!ELEMENT HTML O O (%html.content;) -- document root element --> */
685: Element.HTML.contentModel.add(Element.BODY);
686: Element.HTML.contentModel.add(Element.HEAD);
687: Element.HTML.contentModel.add(Element.FRAMESET);
688: }
689:
690: }
|