2 * @(#)Report.java 1.11 2000/08/16
6 package net.sourceforge.phpdt.tidy.w3c;
10 * Error/informational message reporter.
12 * You should only need to edit the file TidyMessages.properties
13 * to localize HTML tidy.
15 * (c) 1998-2000 (W3C) MIT, INRIA, Keio University
16 * Derived from <a href="http://www.w3.org/People/Raggett/tidy">
17 * HTML Tidy Release 4 Aug 2000</a>
19 * @author Dave Raggett <dsr@w3.org>
20 * @author Andy Quick <ac.quick@sympatico.ca> (translation to Java)
21 * @version 1.0, 1999/05/22
22 * @version 1.0.1, 1999/05/29
23 * @version 1.1, 1999/06/18 Java Bean
24 * @version 1.2, 1999/07/10 Tidy Release 7 Jul 1999
25 * @version 1.3, 1999/07/30 Tidy Release 26 Jul 1999
26 * @version 1.4, 1999/09/04 DOM support
27 * @version 1.5, 1999/10/23 Tidy Release 27 Sep 1999
28 * @version 1.6, 1999/11/01 Tidy Release 22 Oct 1999
29 * @version 1.7, 1999/12/06 Tidy Release 30 Nov 1999
30 * @version 1.8, 2000/01/22 Tidy Release 13 Jan 2000
31 * @version 1.9, 2000/06/03 Tidy Release 30 Apr 2000
32 * @version 1.10, 2000/07/22 Tidy Release 8 Jul 2000
33 * @version 1.11, 2000/08/16 Tidy Release 4 Aug 2000
36 import java.io.PrintWriter;
37 import java.text.MessageFormat;
38 import java.util.Hashtable;
39 import java.util.MissingResourceException;
40 import java.util.ResourceBundle;
42 import net.sourceforge.phpdt.tidy.JTidyConsole;
43 import net.sourceforge.phpdt.tidy.JtidyPlugin;
45 import org.eclipse.core.resources.IMarker;
46 import org.eclipse.core.runtime.CoreException;
47 import org.eclipse.ui.texteditor.MarkerUtilities;
51 /* used to point to Web Accessibility Guidelines */
52 public static final String ACCESS_URL = "http://www.w3.org/WAI/GL";
54 public static final String RELEASE_DATE = "4th August 2000";
56 public static String currentFile;
57 /* sasdjb 01May00 for GNU Emacs error parsing */
59 /* error codes for entities */
61 public static final short MISSING_SEMICOLON = 1;
62 public static final short UNKNOWN_ENTITY = 2;
63 public static final short UNESCAPED_AMPERSAND = 3;
65 /* error codes for element messages */
67 public static final short MISSING_ENDTAG_FOR = 1;
68 public static final short MISSING_ENDTAG_BEFORE = 2;
69 public static final short DISCARDING_UNEXPECTED = 3;
70 public static final short NESTED_EMPHASIS = 4;
71 public static final short NON_MATCHING_ENDTAG = 5;
72 public static final short TAG_NOT_ALLOWED_IN = 6;
73 public static final short MISSING_STARTTAG = 7;
74 public static final short UNEXPECTED_ENDTAG = 8;
75 public static final short USING_BR_INPLACE_OF = 9;
76 public static final short INSERTING_TAG = 10;
77 public static final short SUSPECTED_MISSING_QUOTE = 11;
78 public static final short MISSING_TITLE_ELEMENT = 12;
79 public static final short DUPLICATE_FRAMESET = 13;
80 public static final short CANT_BE_NESTED = 14;
81 public static final short OBSOLETE_ELEMENT = 15;
82 public static final short PROPRIETARY_ELEMENT = 16;
83 public static final short UNKNOWN_ELEMENT = 17;
84 public static final short TRIM_EMPTY_ELEMENT = 18;
85 public static final short COERCE_TO_ENDTAG = 19;
86 public static final short ILLEGAL_NESTING = 20;
87 public static final short NOFRAMES_CONTENT = 21;
88 public static final short CONTENT_AFTER_BODY = 22;
89 public static final short INCONSISTENT_VERSION = 23;
90 public static final short MALFORMED_COMMENT = 24;
91 public static final short BAD_COMMENT_CHARS = 25;
92 public static final short BAD_XML_COMMENT = 26;
93 public static final short BAD_CDATA_CONTENT = 27;
94 public static final short INCONSISTENT_NAMESPACE = 28;
95 public static final short DOCTYPE_AFTER_TAGS = 29;
96 public static final short MALFORMED_DOCTYPE = 30;
97 public static final short UNEXPECTED_END_OF_FILE = 31;
98 public static final short DTYPE_NOT_UPPER_CASE = 32;
99 public static final short TOO_MANY_ELEMENTS = 33;
101 /* error codes used for attribute messages */
103 public static final short UNKNOWN_ATTRIBUTE = 1;
104 public static final short MISSING_ATTRIBUTE = 2;
105 public static final short MISSING_ATTR_VALUE = 3;
106 public static final short BAD_ATTRIBUTE_VALUE = 4;
107 public static final short UNEXPECTED_GT = 5;
108 public static final short PROPRIETARY_ATTR_VALUE = 6;
109 public static final short REPEATED_ATTRIBUTE = 7;
110 public static final short MISSING_IMAGEMAP = 8;
111 public static final short XML_ATTRIBUTE_VALUE = 9;
112 public static final short UNEXPECTED_QUOTEMARK = 10;
113 public static final short ID_NAME_MISMATCH = 11;
115 /* accessibility flaws */
117 public static final short MISSING_IMAGE_ALT = 1;
118 public static final short MISSING_LINK_ALT = 2;
119 public static final short MISSING_SUMMARY = 4;
120 public static final short MISSING_IMAGE_MAP = 8;
121 public static final short USING_FRAMES = 16;
122 public static final short USING_NOFRAMES = 32;
124 /* presentation flaws */
126 public static final short USING_SPACER = 1;
127 public static final short USING_LAYER = 2;
128 public static final short USING_NOBR = 4;
129 public static final short USING_FONT = 8;
130 public static final short USING_BODY = 16;
132 /* character encoding errors */
133 public static final short WINDOWS_CHARS = 1;
134 public static final short NON_ASCII = 2;
135 public static final short FOUND_UTF16 = 4;
137 private static short optionerrors;
139 private static ResourceBundle res = null;
143 res = ResourceBundle.getBundle("net/sourceforge/phpdt/tidy/w3c/TidyMessages");
144 } catch (MissingResourceException e) {
145 throw new Error(e.toString());
149 // public static void tidyPrint(PrintWriter p, String msg) {
153 // public static void tidyPrint(char c) {
154 // // p.println(msg);
155 // // JTidyConsole.print(new String(c));
158 public static void tidyPrint(String msg) {
160 JTidyConsole.print(msg);
163 public static void tidyPrintln(String msg) {
165 JTidyConsole.println(msg);
168 public static void tidyPrintln() {
169 JTidyConsole.println("");
172 public static void showVersion(PrintWriter p) {
173 tidyPrintln("Java HTML Tidy release date: " + RELEASE_DATE);
174 tidyPrintln("See http://www.w3.org/People/Raggett for details");
177 // public static void tag(Lexer lexer, Node tag) {
178 // if (tag != null) {
179 // if (tag.type == Node.StartTag)
180 // tidyPrint(lexer.errout, "<" + tag.element + ">");
181 // else if (tag.type == Node.EndTag)
182 // tidyPrint(lexer.errout, "</" + tag.element + ">");
183 // else if (tag.type == Node.DocTypeTag)
184 // tidyPrint(lexer.errout, "<!DOCTYPE>");
185 // else if (tag.type == Node.TextNode)
186 // tidyPrint(lexer.errout, "plain text");
188 // tidyPrint(lexer.errout, tag.element);
192 public static void tag(StringBuffer errorMessage, Node tag) {
194 if (tag.type == Node.StartTag) {
195 // tidyPrint(lexer.errout, "<" + tag.element + ">");
196 errorMessage.append("<" + tag.element + ">");
197 } else if (tag.type == Node.EndTag) {
198 // tidyPrint(lexer.errout, "</" + tag.element + ">");
199 errorMessage.append("</" + tag.element + ">");
200 } else if (tag.type == Node.DocTypeTag) {
201 // tidyPrint(lexer.errout, "<!DOCTYPE>");
202 errorMessage.append("</" + tag.element + ">");
203 } else if (tag.type == Node.TextNode) {
204 // tidyPrint(lexer.errout, "plain text");
205 errorMessage.append("plain text");
207 // tidyPrint(lexer.errout, tag.element);
208 errorMessage.append(tag.element);
213 /* lexer is not defined when this is called */
214 public static void unknownOption(String option) {
218 MessageFormat.format(
219 res.getString("unknown_option"),
220 new Object[] { option }));
221 } catch (MissingResourceException e) {
222 System.err.println(e.toString());
226 /* lexer is not defined when this is called */
227 public static void badArgument(String option) {
231 MessageFormat.format(
232 res.getString("bad_argument"),
233 new Object[] { option }));
234 } catch (MissingResourceException e) {
235 System.err.println(e.toString());
239 // public static void position(Lexer lexer) {
241 // /* Change formatting to be parsable by GNU Emacs */
242 // if (lexer.configuration.Emacs) {
245 // MessageFormat.format(
246 // res.getString("emacs_format"),
247 // new Object[] { currentFile, new Integer(lexer.lines), new Integer(lexer.columns)}));
248 // tidyPrint(lexer.errout, " ");
249 // } else /* traditional format */ {
252 // MessageFormat.format(res.getString("line_column"), new Object[] { new Integer(lexer.lines), new Integer(lexer.columns)}));
254 // } catch (MissingResourceException e) {
255 // lexer.errout.tidyPrintln(e.toString());
259 public static void encodingError(Lexer lexer, short code, int c) {
262 if (lexer.configuration.ShowWarnings) {
265 if (code == WINDOWS_CHARS) {
266 lexer.badChars |= WINDOWS_CHARS;
268 Hashtable attributes = new Hashtable();
269 StringBuffer errorMessage =
270 new StringBuffer("Column " + lexer.columns + ": ");
271 MarkerUtilities.setLineNumber(attributes, lexer.lines);
272 // tidyPrint(lexer.errout, MessageFormat.format(res.getString("illegal_char"), new Object[] { new Integer(c)}));
274 MessageFormat.format(
275 res.getString("illegal_char"),
276 new Object[] { new Integer(c)}));
279 new Integer(IMarker.SEVERITY_ERROR));
280 attributes.put(JtidyPlugin.MARKER_NAME, Boolean.TRUE);
281 // attributes.put(IMarker.SEVERITY, new Integer(IMarker.SEVERITY_WARNING));
282 // attributes.put(IMarker.SEVERITY, new Integer(IMarker.SEVERITY_INFO));
284 MarkerUtilities.setMessage(
286 errorMessage.toString());
287 MarkerUtilities.createMarker(
291 } catch (CoreException e) {
293 } catch (MissingResourceException e) {
294 tidyPrintln(e.toString());
302 public static void entityError(
309 if (lexer.configuration.ShowWarnings) {
311 Hashtable attributes = new Hashtable();
312 StringBuffer errorMessage =
313 new StringBuffer("Column " + lexer.columns + ": ");
314 MarkerUtilities.setLineNumber(attributes, lexer.lines);
316 if (code == MISSING_SEMICOLON) {
318 // tidyPrint(lexer.errout, MessageFormat.format(res.getString("missing_semicolon"), new Object[] { entity }));
320 MessageFormat.format(
321 res.getString("missing_semicolon"),
322 new Object[] { entity }));
323 } catch (MissingResourceException e) {
324 tidyPrintln(e.toString());
326 } else if (code == UNKNOWN_ENTITY) {
328 // tidyPrint(lexer.errout, MessageFormat.format(res.getString("unknown_entity"), new Object[] { entity }));
330 MessageFormat.format(
331 res.getString("unknown_entity"),
332 new Object[] { entity }));
333 } catch (MissingResourceException e) {
334 tidyPrintln(e.toString());
336 } else if (code == UNESCAPED_AMPERSAND) {
338 // tidyPrint(lexer.errout, res.getString("unescaped_ampersand"));
339 errorMessage.append(res.getString("unescaped_ampersand"));
340 } catch (MissingResourceException e) {
341 tidyPrintln(e.toString());
346 new Integer(IMarker.SEVERITY_ERROR));
347 attributes.put(JtidyPlugin.MARKER_NAME, Boolean.TRUE);
348 // attributes.put(IMarker.SEVERITY, new Integer(IMarker.SEVERITY_WARNING));
349 // attributes.put(IMarker.SEVERITY, new Integer(IMarker.SEVERITY_INFO));
351 MarkerUtilities.setMessage(attributes, errorMessage.toString());
352 MarkerUtilities.createMarker(
356 } catch (CoreException e) {
362 public static void attrError(
369 /* keep quiet after 6 errors */
370 if (lexer.errors > 6)
373 Hashtable attributes = new Hashtable();
374 StringBuffer errorMessage =
375 new StringBuffer("Column " + lexer.columns + ": ");
377 if (lexer.configuration.ShowWarnings) {
378 /* on end of file adjust reported position to end of input */
379 if (code == UNEXPECTED_END_OF_FILE) {
380 lexer.lines = lexer.in.curline;
381 lexer.columns = lexer.in.curcol;
386 MarkerUtilities.setLineNumber(attributes, lexer.lines);
388 if (code == UNKNOWN_ATTRIBUTE) {
390 // tidyPrint(lexer.errout, MessageFormat.format(res.getString("unknown_attribute"), new Object[] { attr }));
392 MessageFormat.format(
393 res.getString("unknown_attribute"),
394 new Object[] { attr }));
395 } catch (MissingResourceException e) {
396 tidyPrintln(e.toString());
398 } else if (code == MISSING_ATTRIBUTE) {
400 // tidyPrint(lexer.errout, res.getString("warning"));
401 errorMessage.append(res.getString("warning"));
402 tag(errorMessage, node);
403 // tidyPrint(lexer.errout, MessageFormat.format(res.getString("missing_attribute"), new Object[] { attr }));
405 MessageFormat.format(
406 res.getString("missing_attribute"),
407 new Object[] { attr }));
408 } catch (MissingResourceException e) {
409 tidyPrintln(e.toString());
411 } else if (code == MISSING_ATTR_VALUE) {
413 // tidyPrint(lexer.errout, res.getString("warning"));
414 errorMessage.append(res.getString("warning"));
415 tag(errorMessage, node);
416 // tidyPrint(lexer.errout, MessageFormat.format(res.getString("missing_attr_value"), new Object[] { attr }));
418 MessageFormat.format(
419 res.getString("missing_attr_value"),
420 new Object[] { attr }));
421 } catch (MissingResourceException e) {
422 tidyPrintln(e.toString());
424 } else if (code == MISSING_IMAGEMAP) {
426 // tidyPrint(lexer.errout, res.getString("warning"));
427 errorMessage.append(res.getString("warning"));
428 tag(errorMessage, node);
429 // tidyPrint(lexer.errout, res.getString("missing_imagemap"));
430 errorMessage.append(res.getString("missing_imagemap"));
431 } catch (MissingResourceException e) {
432 tidyPrintln(e.toString());
434 lexer.badAccess |= MISSING_IMAGE_MAP;
435 } else if (code == BAD_ATTRIBUTE_VALUE) {
437 // tidyPrint(lexer.errout, res.getString("warning"));
438 errorMessage.append(res.getString("warning"));
439 tag(errorMessage, node);
440 // tidyPrint(lexer.errout, MessageFormat.format(res.getString("bad_attribute_value"), new Object[] { attr }));
442 MessageFormat.format(
443 res.getString("bad_attribute_value"),
444 new Object[] { attr }));
445 } catch (MissingResourceException e) {
446 tidyPrintln(e.toString());
448 } else if (code == XML_ATTRIBUTE_VALUE) {
450 // tidyPrint(lexer.errout, res.getString("warning"));
451 errorMessage.append(res.getString("warning"));
452 tag(errorMessage, node);
453 // tidyPrint(lexer.errout, MessageFormat.format(res.getString("xml_attribute_value"), new Object[] { attr }));
455 MessageFormat.format(
456 res.getString("xml_attribute_value"),
457 new Object[] { attr }));
458 } catch (MissingResourceException e) {
459 tidyPrintln(e.toString());
461 } else if (code == UNEXPECTED_GT) {
463 // tidyPrint(lexer.errout, res.getString("error"));
464 errorMessage.append(res.getString("error"));
465 tag(errorMessage, node);
466 // tidyPrint(lexer.errout, res.getString("unexpected_gt"));
467 errorMessage.append(res.getString("unexpected_gt"));
468 } catch (MissingResourceException e) {
469 tidyPrintln(e.toString());
473 } else if (code == UNEXPECTED_QUOTEMARK) {
475 // tidyPrint(lexer.errout, res.getString("warning"));
476 errorMessage.append(res.getString("warning"));
477 tag(errorMessage, node);
478 // tidyPrint(lexer.errout, res.getString("unexpected_quotemark"));
479 errorMessage.append(res.getString("unexpected_quotemark"));
480 } catch (MissingResourceException e) {
481 tidyPrintln(e.toString());
483 } else if (code == REPEATED_ATTRIBUTE) {
485 // tidyPrint(lexer.errout, res.getString("warning"));
486 errorMessage.append(res.getString("warning"));
487 tag(errorMessage, node);
488 // tidyPrint(lexer.errout, res.getString("repeated_attribute"));
489 errorMessage.append(res.getString("repeated_attribute"));
490 } catch (MissingResourceException e) {
491 tidyPrintln(e.toString());
493 } else if (code == PROPRIETARY_ATTR_VALUE) {
495 // tidyPrint(lexer.errout, res.getString("warning"));
496 errorMessage.append(res.getString("warning"));
497 tag(errorMessage, node);
498 // tidyPrint(lexer.errout, MessageFormat.format(res.getString("proprietary_attr_value"), new Object[] { attr }));
500 MessageFormat.format(
501 res.getString("proprietary_attr_value"),
502 new Object[] { attr }));
503 } catch (MissingResourceException e) {
504 tidyPrintln(e.toString());
506 } else if (code == UNEXPECTED_END_OF_FILE) {
508 // tidyPrint(lexer.errout, res.getString("unexpected_end_of_file"));
510 res.getString("unexpected_end_of_file"));
511 } catch (MissingResourceException e) {
512 tidyPrintln(e.toString());
514 } else if (code == ID_NAME_MISMATCH) {
516 // tidyPrint(lexer.errout, res.getString("warning"));
517 errorMessage.append(res.getString("warning"));
518 tag(errorMessage, node);
519 // tidyPrint(lexer.errout, res.getString("id_name_mismatch"));
520 errorMessage.append(res.getString("id_name_mismatch"));
521 } catch (MissingResourceException e) {
522 tidyPrintln(e.toString());
526 // attributes.put(IMarker.SEVERITY, new Integer(IMarker.SEVERITY_ERROR));
529 new Integer(IMarker.SEVERITY_WARNING));
530 // attributes.put(IMarker.SEVERITY, new Integer(IMarker.SEVERITY_INFO));
531 attributes.put(JtidyPlugin.MARKER_NAME, Boolean.TRUE);
533 MarkerUtilities.setMessage(attributes, errorMessage.toString());
534 MarkerUtilities.createMarker(
538 } catch (CoreException e) {
541 } else if (code == UNEXPECTED_GT) {
543 MarkerUtilities.setLineNumber(attributes, lexer.lines);
545 // tidyPrint(lexer.errout, res.getString("error"));
546 errorMessage.append(res.getString("error"));
547 tag(errorMessage, node);
548 // tidyPrint(lexer.errout, res.getString("unexpected_gt"));
549 errorMessage.append(res.getString("unexpected_gt"));
552 new Integer(IMarker.SEVERITY_ERROR));
553 // attributes.put(IMarker.SEVERITY, new Integer(IMarker.SEVERITY_WARNING));
554 // attributes.put(IMarker.SEVERITY, new Integer(IMarker.SEVERITY_INFO));
555 attributes.put(JtidyPlugin.MARKER_NAME, Boolean.TRUE);
557 MarkerUtilities.setMessage(
559 errorMessage.toString());
560 MarkerUtilities.createMarker(
564 } catch (CoreException e) {
566 } catch (MissingResourceException e) {
567 tidyPrintln(e.toString());
576 public static void warning(
583 TagTable tt = lexer.configuration.tt;
587 /* keep quiet after 6 errors */
588 if (lexer.errors > 6)
591 if (lexer.configuration.ShowWarnings) {
593 /* on end of file adjust reported position to end of input */
594 if (code == UNEXPECTED_END_OF_FILE) {
595 lexer.lines = lexer.in.curline;
596 lexer.columns = lexer.in.curcol;
600 Hashtable attributes = new Hashtable();
601 StringBuffer errorMessage =
602 new StringBuffer("Column " + lexer.columns + ": ");
604 MarkerUtilities.setLineNumber(attributes, lexer.lines);
606 if (code == MISSING_ENDTAG_FOR) {
608 // tidyPrint(lexer.errout, MessageFormat.format(res.getString("missing_endtag_for"), new Object[] { element.element }));
610 MessageFormat.format(
611 res.getString("missing_endtag_for"),
612 new Object[] { element.element }));
613 } catch (MissingResourceException e) {
614 tidyPrintln(e.toString());
616 } else if (code == MISSING_ENDTAG_BEFORE) {
618 // tidyPrint(lexer.errout, MessageFormat.format(res.getString("missing_endtag_before"), new Object[] { element.element }));
620 MessageFormat.format(
621 res.getString("missing_endtag_before"),
622 new Object[] { element.element }));
624 } catch (MissingResourceException e) {
625 tidyPrintln(e.toString());
627 tag(errorMessage, node);
628 } else if (code == DISCARDING_UNEXPECTED) {
629 //REVISIT: DIscarding... message
632 // // tidyPrint(lexer.errout, res.getString("discarding_unexpected"));
633 // errorMessage.append(res.getString("discarding_unexpected"));
634 // } catch (MissingResourceException e) {
635 // tidyPrintln(e.toString());
637 // tag(errorMessage, lexer, node);
638 } else if (code == NESTED_EMPHASIS) {
640 // tidyPrint(lexer.errout, res.getString("nested_emphasis"));
641 errorMessage.append(res.getString("nested_emphasis"));
642 } catch (MissingResourceException e) {
643 tidyPrintln(e.toString());
645 tag(errorMessage, node);
646 } else if (code == COERCE_TO_ENDTAG) {
648 // tidyPrint(lexer.errout, MessageFormat.format(res.getString("coerce_to_endtag"), new Object[] { element.element }));
650 MessageFormat.format(
651 res.getString("coerce_to_endtag"),
652 new Object[] { element.element }));
653 } catch (MissingResourceException e) {
654 tidyPrintln(e.toString());
656 } else if (code == NON_MATCHING_ENDTAG) {
658 // tidyPrint(lexer.errout, res.getString("non_matching_endtag_1"));
659 errorMessage.append(res.getString("non_matching_endtag_1"));
660 } catch (MissingResourceException e) {
661 tidyPrintln(e.toString());
663 tag(errorMessage, node);
665 // tidyPrint(lexer.errout, MessageFormat.format(res.getString("non_matching_endtag_2"), new Object[] { element.element }));
667 MessageFormat.format(
668 res.getString("non_matching_endtag_2"),
669 new Object[] { element.element }));
670 } catch (MissingResourceException e) {
671 tidyPrintln(e.toString());
673 } else if (code == TAG_NOT_ALLOWED_IN) {
675 // tidyPrint(lexer.errout, res.getString("warning"));
676 errorMessage.append(res.getString("warning"));
677 } catch (MissingResourceException e) {
678 tidyPrintln(e.toString());
680 tag(errorMessage, node);
682 // tidyPrint(lexer.errout, MessageFormat.format(res.getString("tag_not_allowed_in"), new Object[] { element.element }));
684 MessageFormat.format(
685 res.getString("tag_not_allowed_in"),
686 new Object[] { element.element }));
687 } catch (MissingResourceException e) {
688 tidyPrintln(e.toString());
690 } else if (code == DOCTYPE_AFTER_TAGS) {
692 // tidyPrint(lexer.errout, res.getString("doctype_after_tags"));
693 errorMessage.append(res.getString("doctype_after_tags"));
694 } catch (MissingResourceException e) {
695 tidyPrintln(e.toString());
697 } else if (code == MISSING_STARTTAG) {
699 // tidyPrint(lexer.errout, MessageFormat.format(res.getString("missing_starttag"), new Object[] { node.element }));
701 MessageFormat.format(
702 res.getString("missing_starttag"),
703 new Object[] { node.element }));
704 } catch (MissingResourceException e) {
705 tidyPrintln(e.toString());
707 } else if (code == UNEXPECTED_ENDTAG) {
709 // tidyPrint(lexer.errout, MessageFormat.format(res.getString("unexpected_endtag"), new Object[] { node.element }));
713 // MessageFormat.format(res.getString("unexpected_endtag_suffix"), new Object[] { element.element }));
715 MessageFormat.format(
716 res.getString("unexpected_endtag"),
717 new Object[] { node.element }));
718 } catch (MissingResourceException e) {
719 tidyPrintln(e.toString());
721 } else if (code == TOO_MANY_ELEMENTS) {
723 // tidyPrint(lexer.errout, MessageFormat.format(res.getString("too_many_elements"), new Object[] { node.element }));
727 // MessageFormat.format(res.getString("too_many_elements_suffix"), new Object[] { element.element }));
729 MessageFormat.format(
730 res.getString("too_many_elements"),
731 new Object[] { node.element }));
732 } catch (MissingResourceException e) {
733 tidyPrintln(e.toString());
735 } else if (code == USING_BR_INPLACE_OF) {
737 // tidyPrint(lexer.errout, res.getString("using_br_inplace_of"));
738 errorMessage.append(res.getString("using_br_inplace_of"));
739 } catch (MissingResourceException e) {
740 tidyPrintln(e.toString());
742 tag(errorMessage, node);
743 } else if (code == INSERTING_TAG) {
745 // tidyPrint(lexer.errout, MessageFormat.format(res.getString("inserting_tag"), new Object[] { node.element }));
747 MessageFormat.format(
748 res.getString("inserting_tag"),
749 new Object[] { node.element }));
750 } catch (MissingResourceException e) {
751 tidyPrintln(e.toString());
753 } else if (code == CANT_BE_NESTED) {
755 // tidyPrint(lexer.errout, res.getString("warning"));
756 errorMessage.append(res.getString("warning"));
757 } catch (MissingResourceException e) {
758 tidyPrintln(e.toString());
760 tag(errorMessage, node);
762 // tidyPrint(lexer.errout, res.getString("cant_be_nested"));
763 errorMessage.append(res.getString("cant_be_nested"));
764 } catch (MissingResourceException e) {
765 tidyPrintln(e.toString());
767 } else if (code == PROPRIETARY_ELEMENT) {
769 // tidyPrint(lexer.errout, res.getString("warning"));
770 errorMessage.append(res.getString("warning"));
771 } catch (MissingResourceException e) {
772 tidyPrintln(e.toString());
774 tag(errorMessage, node);
776 // tidyPrint(lexer.errout, res.getString("proprietary_element"));
777 errorMessage.append(res.getString("proprietary_element"));
778 } catch (MissingResourceException e) {
779 tidyPrintln(e.toString());
782 if (node.tag == tt.tagLayer)
783 lexer.badLayout |= USING_LAYER;
784 else if (node.tag == tt.tagSpacer)
785 lexer.badLayout |= USING_SPACER;
786 else if (node.tag == tt.tagNobr)
787 lexer.badLayout |= USING_NOBR;
788 } else if (code == OBSOLETE_ELEMENT) {
790 if (element.tag != null
791 && (element.tag.model & Dict.CM_OBSOLETE) != 0) {
792 // tidyPrint(lexer.errout, res.getString("obsolete_element"));
793 errorMessage.append(res.getString("obsolete_element"));
795 // tidyPrint(lexer.errout, res.getString("replacing_element"));
796 errorMessage.append(res.getString("replacing_element"));
799 } catch (MissingResourceException e) {
800 tidyPrintln(e.toString());
802 tag(errorMessage, element);
804 // tidyPrint(lexer.errout, res.getString("by"));
805 errorMessage.append(res.getString("by"));
806 } catch (MissingResourceException e) {
807 tidyPrintln(e.toString());
809 tag(errorMessage, node);
810 } else if (code == TRIM_EMPTY_ELEMENT) {
812 // tidyPrint(lexer.errout, res.getString("trim_empty_element"));
813 errorMessage.append(res.getString("trim_empty_element"));
814 } catch (MissingResourceException e) {
815 tidyPrintln(e.toString());
817 tag(errorMessage, element);
818 } else if (code == MISSING_TITLE_ELEMENT) {
820 // tidyPrint(lexer.errout, res.getString("missing_title_element"));
821 errorMessage.append(res.getString("missing_title_element"));
822 } catch (MissingResourceException e) {
823 tidyPrintln(e.toString());
825 } else if (code == ILLEGAL_NESTING) {
827 // tidyPrint(lexer.errout, res.getString("warning"));
828 errorMessage.append(res.getString("warning"));
829 } catch (MissingResourceException e) {
830 tidyPrintln(e.toString());
832 tag(errorMessage, element);
834 // tidyPrint(lexer.errout, res.getString("illegal_nesting"));
835 errorMessage.append(res.getString("illegal_nesting"));
836 } catch (MissingResourceException e) {
837 tidyPrintln(e.toString());
839 } else if (code == NOFRAMES_CONTENT) {
841 // tidyPrint(lexer.errout, res.getString("warning"));
842 errorMessage.append(res.getString("warning"));
843 } catch (MissingResourceException e) {
844 tidyPrintln(e.toString());
846 tag(errorMessage, node);
848 // tidyPrint(lexer.errout, res.getString("noframes_content"));
849 errorMessage.append(res.getString("noframes_content"));
850 } catch (MissingResourceException e) {
851 tidyPrintln(e.toString());
853 } else if (code == INCONSISTENT_VERSION) {
855 // tidyPrint(lexer.errout, res.getString("inconsistent_version"));
856 errorMessage.append(res.getString("inconsistent_version"));
857 } catch (MissingResourceException e) {
858 tidyPrintln(e.toString());
860 } else if (code == MALFORMED_DOCTYPE) {
862 // tidyPrint(lexer.errout, res.getString("malformed_doctype"));
863 errorMessage.append(res.getString("malformed_doctype"));
864 } catch (MissingResourceException e) {
865 tidyPrintln(e.toString());
867 } else if (code == CONTENT_AFTER_BODY) {
869 // tidyPrint(lexer.errout, res.getString("content_after_body"));
870 errorMessage.append(res.getString("content_after_body"));
871 } catch (MissingResourceException e) {
872 tidyPrintln(e.toString());
874 } else if (code == MALFORMED_COMMENT) {
876 // tidyPrint(lexer.errout, res.getString("malformed_comment"));
877 errorMessage.append(res.getString("malformed_comment"));
878 } catch (MissingResourceException e) {
879 tidyPrintln(e.toString());
881 } else if (code == BAD_COMMENT_CHARS) {
883 // tidyPrint(lexer.errout, res.getString("bad_comment_chars"));
884 errorMessage.append(res.getString("bad_comment_chars"));
885 } catch (MissingResourceException e) {
886 tidyPrintln(e.toString());
888 } else if (code == BAD_XML_COMMENT) {
890 // tidyPrint(lexer.errout, res.getString("bad_xml_comment"));
891 errorMessage.append(res.getString("bad_xml_comment"));
892 } catch (MissingResourceException e) {
893 tidyPrintln(e.toString());
895 } else if (code == BAD_CDATA_CONTENT) {
897 // tidyPrint(lexer.errout, res.getString("bad_cdata_content"));
898 errorMessage.append(res.getString("bad_cdata_content"));
899 } catch (MissingResourceException e) {
900 tidyPrintln(e.toString());
902 } else if (code == INCONSISTENT_NAMESPACE) {
904 // tidyPrint(lexer.errout, res.getString("inconsistent_namespace"));
906 res.getString("inconsistent_namespace"));
907 } catch (MissingResourceException e) {
908 tidyPrintln(e.toString());
910 } else if (code == DTYPE_NOT_UPPER_CASE) {
912 // tidyPrint(lexer.errout, res.getString("dtype_not_upper_case"));
913 errorMessage.append(res.getString("dtype_not_upper_case"));
914 } catch (MissingResourceException e) {
915 tidyPrintln(e.toString());
917 } else if (code == UNEXPECTED_END_OF_FILE) {
919 // tidyPrint(lexer.errout, res.getString("unexpected_end_of_file"));
921 res.getString("unexpected_end_of_file"));
922 } catch (MissingResourceException e) {
923 tidyPrintln(e.toString());
925 tag(errorMessage, element);
927 // attributes.put(IMarker.SEVERITY, new Integer(IMarker.SEVERITY_ERROR));
930 new Integer(IMarker.SEVERITY_WARNING));
931 attributes.put(JtidyPlugin.MARKER_NAME, Boolean.TRUE);
932 // attributes.put(IMarker.SEVERITY, new Integer(IMarker.SEVERITY_INFO));
934 MarkerUtilities.setMessage(attributes, errorMessage.toString());
935 MarkerUtilities.createMarker(
939 } catch (CoreException e) {
945 public static void error(
952 /* keep quiet after 6 errors */
953 if (lexer.errors > 6)
960 Hashtable attributes = new Hashtable();
961 StringBuffer errorMessage =
962 new StringBuffer("Column " + lexer.columns + ": ");
964 MarkerUtilities.setLineNumber(attributes, lexer.lines);
966 if (code == SUSPECTED_MISSING_QUOTE) {
968 // tidyPrint(lexer.errout, res.getString("suspected_missing_quote"));
969 errorMessage.append(res.getString("suspected_missing_quote"));
971 } catch (MissingResourceException e) {
972 tidyPrintln(e.toString());
974 } else if (code == DUPLICATE_FRAMESET) {
976 // tidyPrint(lexer.errout, res.getString("duplicate_frameset"));
977 errorMessage.append(res.getString("duplicate_frameset"));
978 } catch (MissingResourceException e) {
979 tidyPrintln(e.toString());
981 } else if (code == UNKNOWN_ELEMENT) {
983 // tidyPrint(lexer.errout, res.getString("error"));
984 errorMessage.append(res.getString("error"));
985 } catch (MissingResourceException e) {
986 tidyPrintln(e.toString());
988 tag(errorMessage, node);
990 // tidyPrint(lexer.errout, res.getString("unknown_element"));
991 errorMessage.append(res.getString("unknown_element"));
992 } catch (MissingResourceException e) {
993 tidyPrintln(e.toString());
995 } else if (code == UNEXPECTED_ENDTAG) {
997 // tidyPrint(lexer.errout, MessageFormat.format(res.getString("unexpected_endtag"), new Object[] { node.element }));
999 MessageFormat.format(
1000 res.getString("unexpected_endtag"),
1001 new Object[] { node.element }));
1002 if (element != null) {
1005 // MessageFormat.format(res.getString("unexpected_endtag_suffix"), new Object[] { element.element }));
1006 // errorMessage.append(MessageFormat.format(res.getString("unexpected_endtag_suffix"), new Object[] { element.element }));
1008 } catch (MissingResourceException e) {
1009 tidyPrintln(e.toString());
1012 attributes.put(IMarker.SEVERITY, new Integer(IMarker.SEVERITY_ERROR));
1013 // attributes.put(IMarker.SEVERITY, new Integer(IMarker.SEVERITY_WARNING));
1014 // attributes.put(IMarker.SEVERITY, new Integer(IMarker.SEVERITY_INFO));
1015 attributes.put(JtidyPlugin.MARKER_NAME, Boolean.TRUE);
1017 MarkerUtilities.setMessage(attributes, errorMessage.toString());
1018 MarkerUtilities.createMarker(
1022 } catch (CoreException e) {
1024 // tidyPrintln(lexer.errout);
1027 public static void errorSummary(Lexer lexer) {
1028 /* adjust badAccess to that its null if frames are ok */
1029 if ((lexer.badAccess & (USING_FRAMES | USING_NOFRAMES)) != 0) {
1030 if (!(((lexer.badAccess & USING_FRAMES) != 0)
1031 && ((lexer.badAccess & USING_NOFRAMES) == 0)))
1032 lexer.badAccess &= ~(USING_FRAMES | USING_NOFRAMES);
1035 Hashtable attributes = new Hashtable();
1036 StringBuffer errorMessage =
1037 new StringBuffer("Column " + lexer.columns + ": ");
1039 MarkerUtilities.setLineNumber(attributes, lexer.lines);
1041 if (lexer.badChars != 0) {
1042 if ((lexer.badChars & WINDOWS_CHARS) != 0) {
1044 // tidyPrint(lexer.errout, res.getString("badchars_summary"));
1045 errorMessage.append(res.getString("badchars_summary"));
1046 } catch (MissingResourceException e) {
1047 tidyPrintln(e.toString());
1052 if (lexer.badForm != 0) {
1054 // tidyPrint(lexer.errout, res.getString("badform_summary"));
1055 errorMessage.append(res.getString("badform_summary"));
1056 } catch (MissingResourceException e) {
1057 tidyPrintln(e.toString());
1061 if (lexer.badAccess != 0) {
1062 if ((lexer.badAccess & MISSING_SUMMARY) != 0) {
1064 // tidyPrint(lexer.errout, res.getString("badaccess_missing_summary"));
1065 errorMessage.append(
1066 res.getString("badaccess_missing_summary"));
1067 } catch (MissingResourceException e) {
1068 tidyPrintln(e.toString());
1072 if ((lexer.badAccess & MISSING_IMAGE_ALT) != 0) {
1074 // tidyPrint(lexer.errout, res.getString("badaccess_missing_image_alt"));
1075 errorMessage.append(
1076 res.getString("badaccess_missing_image_alt"));
1077 } catch (MissingResourceException e) {
1078 tidyPrintln(e.toString());
1082 if ((lexer.badAccess & MISSING_IMAGE_MAP) != 0) {
1084 // tidyPrint(lexer.errout, res.getString("badaccess_missing_image_map"));
1085 errorMessage.append(
1086 res.getString("badaccess_missing_image_map"));
1087 } catch (MissingResourceException e) {
1088 tidyPrintln(e.toString());
1092 if ((lexer.badAccess & MISSING_LINK_ALT) != 0) {
1094 // tidyPrint(lexer.errout, res.getString("badaccess_missing_link_alt"));
1095 errorMessage.append(
1096 res.getString("badaccess_missing_link_alt"));
1097 } catch (MissingResourceException e) {
1098 tidyPrintln(e.toString());
1102 if (((lexer.badAccess & USING_FRAMES) != 0)
1103 && ((lexer.badAccess & USING_NOFRAMES) == 0)) {
1105 // tidyPrint(lexer.errout, res.getString("badaccess_frames"));
1106 errorMessage.append(res.getString("badaccess_frames"));
1107 } catch (MissingResourceException e) {
1108 tidyPrintln(e.toString());
1113 // tidyPrint(lexer.errout, MessageFormat.format(res.getString("badaccess_summary"), new Object[] { ACCESS_URL }));
1114 errorMessage.append(
1115 MessageFormat.format(
1116 res.getString("badaccess_summary"),
1117 new Object[] { ACCESS_URL }));
1118 } catch (MissingResourceException e) {
1119 tidyPrintln(e.toString());
1123 if (lexer.badLayout != 0) {
1124 if ((lexer.badLayout & USING_LAYER) != 0) {
1126 // tidyPrint(lexer.errout, res.getString("badlayout_using_layer"));
1127 errorMessage.append(res.getString("badlayout_using_layer"));
1128 } catch (MissingResourceException e) {
1129 tidyPrintln(e.toString());
1133 if ((lexer.badLayout & USING_SPACER) != 0) {
1135 // tidyPrint(lexer.errout, res.getString("badlayout_using_spacer"));
1136 errorMessage.append(
1137 res.getString("badlayout_using_spacer"));
1138 } catch (MissingResourceException e) {
1139 tidyPrintln(e.toString());
1143 if ((lexer.badLayout & USING_FONT) != 0) {
1145 // tidyPrint(lexer.errout, res.getString("badlayout_using_font"));
1146 errorMessage.append(res.getString("badlayout_using_font"));
1147 } catch (MissingResourceException e) {
1148 tidyPrintln(e.toString());
1152 if ((lexer.badLayout & USING_NOBR) != 0) {
1154 // tidyPrint(lexer.errout, res.getString("badlayout_using_nobr"));
1155 errorMessage.append(res.getString("badlayout_using_nobr"));
1156 } catch (MissingResourceException e) {
1157 tidyPrintln(e.toString());
1161 if ((lexer.badLayout & USING_BODY) != 0) {
1163 // tidyPrint(lexer.errout, res.getString("badlayout_using_body"));
1164 errorMessage.append(res.getString("badlayout_using_body"));
1165 } catch (MissingResourceException e) {
1166 tidyPrintln(e.toString());
1171 new Integer(IMarker.SEVERITY_ERROR));
1172 // attributes.put(IMarker.SEVERITY, new Integer(IMarker.SEVERITY_WARNING));
1173 // attributes.put(IMarker.SEVERITY, new Integer(IMarker.SEVERITY_INFO));
1174 attributes.put(JtidyPlugin.MARKER_NAME, Boolean.TRUE);
1176 MarkerUtilities.setMessage(attributes, errorMessage.toString());
1177 MarkerUtilities.createMarker(
1181 } catch (CoreException e) {
1186 public static void unknownOption(PrintWriter errout, char c) {
1189 MessageFormat.format(
1190 res.getString("unrecognized_option"),
1191 new Object[] { new String(new char[] { c })
1193 } catch (MissingResourceException e) {
1194 tidyPrintln(e.toString());
1198 public static void unknownFile(
1204 MessageFormat.format(
1205 res.getString("unknown_file"),
1206 new Object[] { program, file }));
1207 } catch (MissingResourceException e) {
1208 tidyPrintln(e.toString());
1212 public static void needsAuthorIntervention(PrintWriter errout) {
1214 tidyPrintln(res.getString("needs_author_intervention"));
1215 } catch (MissingResourceException e) {
1216 tidyPrintln(e.toString());
1220 public static void missingBody(PrintWriter errout) {
1222 tidyPrintln(res.getString("missing_body"));
1223 } catch (MissingResourceException e) {
1224 tidyPrintln(e.toString());
1228 public static void reportNumberOfSlides(PrintWriter errout, int count) {
1231 MessageFormat.format(
1232 res.getString("slides_found"),
1233 new Object[] { new Integer(count)}));
1234 } catch (MissingResourceException e) {
1235 tidyPrintln(e.toString());
1239 public static void generalInfo(PrintWriter errout) {
1241 tidyPrintln(res.getString("general_info"));
1242 } catch (MissingResourceException e) {
1243 tidyPrintln(e.toString());
1247 public static void helloMessage(
1251 currentFile = filename; /* for use with Gnu Emacs */
1255 MessageFormat.format(
1256 res.getString("hello_message"),
1257 new Object[] { date, filename }));
1258 } catch (MissingResourceException e) {
1259 tidyPrintln(e.toString());
1263 public static void reportVersion(
1270 String vers = lexer.HTMLVersionName();
1271 MutableInteger cc = new MutableInteger();
1274 if (doctype != null) {
1276 MessageFormat.format(
1277 res.getString("doctype_given"),
1278 new Object[] { filename }));
1279 StringBuffer buf = new StringBuffer();
1280 for (i = doctype.start; i < doctype.end; ++i) {
1281 c = (int) doctype.textarray[i];
1283 /* look for UTF-8 multibyte character */
1285 i += PPrint.getUTF8(doctype.textarray, i, cc);
1289 if (c == (char) '"')
1291 else if (state == 1) {
1293 // tidyPrint((char) c);
1299 tidyPrint( buf.toString() );
1303 MessageFormat.format(
1304 res.getString("report_version"),
1307 (vers != null ? vers : "HTML proprietary")}));
1308 } catch (MissingResourceException e) {
1309 tidyPrintln(e.toString());
1313 public static void reportNumWarnings(PrintWriter errout, Lexer lexer) {
1314 if (lexer.warnings > 0) {
1317 MessageFormat.format(
1318 res.getString("num_warnings"),
1319 new Object[] { new Integer(lexer.warnings)}));
1320 } catch (MissingResourceException e) {
1321 tidyPrintln(e.toString());
1325 tidyPrintln(res.getString("no_warnings"));
1326 } catch (MissingResourceException e) {
1327 tidyPrintln(e.toString());
1332 public static void helpText(PrintWriter out, String prog) {
1335 MessageFormat.format(
1336 res.getString("help_text"),
1337 new Object[] { prog, RELEASE_DATE }));
1338 } catch (MissingResourceException e) {
1339 tidyPrintln(e.toString());
1343 public static void badTree(PrintWriter errout) {
1345 tidyPrintln(res.getString("bad_tree"));
1346 } catch (MissingResourceException e) {
1347 tidyPrintln(e.toString());