1 package mir.util.xml.html;
3 import java.util.ArrayList;
4 import java.util.HashMap;
8 public class HTMLSchemaInformation {
11 public HTMLSchemaInformation() {
16 addInlineTag("acronym");
17 addInlineTag("address");
18 addInlineTag("applet");
22 addInlineTag("basefont");
25 addInlineTag("blockquote");
26 addBlockTag("body", new String[] {"head"});
28 addBodylessTag("button");
29 addInlineTag("caption");
30 addInlineTag("center");
34 addInlineTag("colgroup");
43 addInlineTag("fieldset");
44 // Zapata: Removed because of frequent abuse by html writers
45 // addInlineTag("font");
47 addBodylessTag("frame");
48 addInlineTag("frameset");
59 addBlockTag("iframe");
60 addBodylessTag("img");
61 addBodylessTag("input");
63 addInlineTag("isindex");
65 addInlineTag("label");
66 addInlineTag("legend");
71 addBodylessTag("meta");
72 addBlockTag("noframes");
73 addInlineTag("noscript");
74 addBodylessTag("object");
76 addInlineTag("optgroup");
77 addInlineTag("option");
78 addBlockTag("p", new String[] {"p"});
79 addInlineTag("param");
84 addInlineTag("script");
85 addInlineTag("select");
86 addInlineTag("small");
88 addInlineTag("strike");
89 addInlineTag("strong");
90 addInlineTag("style");
95 addBlockTag("td", new String[] {"td", "th"});
96 addInlineTag("textarea");
97 addInlineTag("tfoot");
98 addBlockTag("th", new String[] {"td", "th"});
99 addInlineTag("thead");
100 addInlineTag("title");
101 addBlockTag("tr", new String[] {"td", "th", "tr"});
108 public HTMLTagInformation lookupTag(String aTag) {
109 return (HTMLTagInformation) tags.get(aTag);
112 public void addInlineTag(String aTagName) {
113 addTag(aTagName, false, true, null);
116 public void addBodylessTag(String aTagName) {
117 addTag(aTagName, false, false, null);
120 public void addBlockTag(String aTagName) {
121 addTag(aTagName, true, true, null);
124 public void addBlockTag(String aTagName, String[] anAutoCloseList) {
125 addTag(aTagName, true, true, anAutoCloseList);
128 public void addTag(String aTagName, boolean anIsBlock, boolean aHasBody, String[] anAutoCloseList) {
129 HTMLTagInformation tagInformation = new HTMLTagInformation(aTagName, anIsBlock, aHasBody);
131 if (anAutoCloseList!=null) {
132 for (int i = 0; i < anAutoCloseList.length; i++) {
133 tagInformation.addAutoClosedTag(anAutoCloseList[i]);
137 tags.put(aTagName, tagInformation);
140 public class HTMLTagInformation {
141 private boolean isBlock;
142 private boolean hasBody;
143 private String tagName;
144 private List autoCloseList;
146 public HTMLTagInformation(String aTagName, boolean anIsBlock, boolean aHasBody) {
150 autoCloseList = new ArrayList();
153 void addAutoClosedTag(String aTag) {
154 autoCloseList.add(aTag);
157 public boolean autoClose(String aTag) {
158 return autoCloseList.contains(aTag);
161 public boolean getIsBlock() {
165 public boolean getHasBody() {
169 public String getTagName() {