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;
44 import org.eclipse.core.resources.IMarker;
45 import org.eclipse.core.runtime.CoreException;
46 import org.eclipse.ui.texteditor.MarkerUtilities;
50 /* used to point to Web Accessibility Guidelines */
51 public static final String ACCESS_URL = "http://www.w3.org/WAI/GL";
53 public static final String RELEASE_DATE = "4th August 2000";
55 public static String currentFile;
56 /* sasdjb 01May00 for GNU Emacs error parsing */
58 /* error codes for entities */
60 public static final short MISSING_SEMICOLON = 1;
61 public static final short UNKNOWN_ENTITY = 2;
62 public static final short UNESCAPED_AMPERSAND = 3;
64 /* error codes for element messages */
66 public static final short MISSING_ENDTAG_FOR = 1;
67 public static final short MISSING_ENDTAG_BEFORE = 2;
68 public static final short DISCARDING_UNEXPECTED = 3;
69 public static final short NESTED_EMPHASIS = 4;
70 public static final short NON_MATCHING_ENDTAG = 5;
71 public static final short TAG_NOT_ALLOWED_IN = 6;
72 public static final short MISSING_STARTTAG = 7;
73 public static final short UNEXPECTED_ENDTAG = 8;
74 public static final short USING_BR_INPLACE_OF = 9;
75 public static final short INSERTING_TAG = 10;
76 public static final short SUSPECTED_MISSING_QUOTE = 11;
77 public static final short MISSING_TITLE_ELEMENT = 12;
78 public static final short DUPLICATE_FRAMESET = 13;
79 public static final short CANT_BE_NESTED = 14;
80 public static final short OBSOLETE_ELEMENT = 15;
81 public static final short PROPRIETARY_ELEMENT = 16;
82 public static final short UNKNOWN_ELEMENT = 17;
83 public static final short TRIM_EMPTY_ELEMENT = 18;
84 public static final short COERCE_TO_ENDTAG = 19;
85 public static final short ILLEGAL_NESTING = 20;
86 public static final short NOFRAMES_CONTENT = 21;
87 public static final short CONTENT_AFTER_BODY = 22;
88 public static final short INCONSISTENT_VERSION = 23;
89 public static final short MALFORMED_COMMENT = 24;
90 public static final short BAD_COMMENT_CHARS = 25;
91 public static final short BAD_XML_COMMENT = 26;
92 public static final short BAD_CDATA_CONTENT = 27;
93 public static final short INCONSISTENT_NAMESPACE = 28;
94 public static final short DOCTYPE_AFTER_TAGS = 29;
95 public static final short MALFORMED_DOCTYPE = 30;
96 public static final short UNEXPECTED_END_OF_FILE = 31;
97 public static final short DTYPE_NOT_UPPER_CASE = 32;
98 public static final short TOO_MANY_ELEMENTS = 33;
100 /* error codes used for attribute messages */
102 public static final short UNKNOWN_ATTRIBUTE = 1;
103 public static final short MISSING_ATTRIBUTE = 2;
104 public static final short MISSING_ATTR_VALUE = 3;
105 public static final short BAD_ATTRIBUTE_VALUE = 4;
106 public static final short UNEXPECTED_GT = 5;
107 public static final short PROPRIETARY_ATTR_VALUE = 6;
108 public static final short REPEATED_ATTRIBUTE = 7;
109 public static final short MISSING_IMAGEMAP = 8;
110 public static final short XML_ATTRIBUTE_VALUE = 9;
111 public static final short UNEXPECTED_QUOTEMARK = 10;
112 public static final short ID_NAME_MISMATCH = 11;
114 /* accessibility flaws */
116 public static final short MISSING_IMAGE_ALT = 1;
117 public static final short MISSING_LINK_ALT = 2;
118 public static final short MISSING_SUMMARY = 4;
119 public static final short MISSING_IMAGE_MAP = 8;
120 public static final short USING_FRAMES = 16;
121 public static final short USING_NOFRAMES = 32;
123 /* presentation flaws */
125 public static final short USING_SPACER = 1;
126 public static final short USING_LAYER = 2;
127 public static final short USING_NOBR = 4;
128 public static final short USING_FONT = 8;
129 public static final short USING_BODY = 16;
131 /* character encoding errors */
132 public static final short WINDOWS_CHARS = 1;
133 public static final short NON_ASCII = 2;
134 public static final short FOUND_UTF16 = 4;
136 private static short optionerrors;
138 private static ResourceBundle res = null;
142 res = ResourceBundle.getBundle("net/sourceforge/phpdt/tidy/w3c/TidyMessages");
143 } catch (MissingResourceException e) {
144 throw new Error(e.toString());
148 // public static void tidyPrint(PrintWriter p, String msg) {
152 // public static void tidyPrint(char c) {
153 // // p.println(msg);
154 // // JTidyConsole.print(new String(c));
157 public static void tidyPrint(String msg) {
159 JTidyConsole.print(msg);
162 public static void tidyPrintln(String msg) {
164 JTidyConsole.println(msg);
167 public static void tidyPrintln() {
168 JTidyConsole.println("");
171 public static void showVersion(PrintWriter p) {
172 tidyPrintln("Java HTML Tidy release date: " + RELEASE_DATE);
173 tidyPrintln("See http://www.w3.org/People/Raggett for details");
176 // public static void tag(Lexer lexer, Node tag) {
177 // if (tag != null) {
178 // if (tag.type == Node.StartTag)
179 // tidyPrint(lexer.errout, "<" + tag.element + ">");
180 // else if (tag.type == Node.EndTag)
181 // tidyPrint(lexer.errout, "</" + tag.element + ">");
182 // else if (tag.type == Node.DocTypeTag)
183 // tidyPrint(lexer.errout, "<!DOCTYPE>");
184 // else if (tag.type == Node.TextNode)
185 // tidyPrint(lexer.errout, "plain text");
187 // tidyPrint(lexer.errout, tag.element);
191 public static void tag(StringBuffer errorMessage, Node tag) {
193 if (tag.type == Node.StartTag) {
194 // tidyPrint(lexer.errout, "<" + tag.element + ">");
195 errorMessage.append("<" + tag.element + ">");
196 } else if (tag.type == Node.EndTag) {
197 // tidyPrint(lexer.errout, "</" + tag.element + ">");
198 errorMessage.append("</" + tag.element + ">");
199 } else if (tag.type == Node.DocTypeTag) {
200 // tidyPrint(lexer.errout, "<!DOCTYPE>");
201 errorMessage.append("</" + tag.element + ">");
202 } else if (tag.type == Node.TextNode) {
203 // tidyPrint(lexer.errout, "plain text");
204 errorMessage.append("plain text");
206 // tidyPrint(lexer.errout, tag.element);
207 errorMessage.append(tag.element);
212 /* lexer is not defined when this is called */
213 public static void unknownOption(String option) {
217 MessageFormat.format(
218 res.getString("unknown_option"),
219 new Object[] { option }));
220 } catch (MissingResourceException e) {
221 System.err.println(e.toString());
225 /* lexer is not defined when this is called */
226 public static void badArgument(String option) {
230 MessageFormat.format(
231 res.getString("bad_argument"),
232 new Object[] { option }));
233 } catch (MissingResourceException e) {
234 System.err.println(e.toString());
238 // public static void position(Lexer lexer) {
240 // /* Change formatting to be parsable by GNU Emacs */
241 // if (lexer.configuration.Emacs) {
244 // MessageFormat.format(
245 // res.getString("emacs_format"),
246 // new Object[] { currentFile, new Integer(lexer.lines), new Integer(lexer.columns)}));
247 // tidyPrint(lexer.errout, " ");
248 // } else /* traditional format */ {
251 // MessageFormat.format(res.getString("line_column"), new Object[] { new Integer(lexer.lines), new Integer(lexer.columns)}));
253 // } catch (MissingResourceException e) {
254 // lexer.errout.tidyPrintln(e.toString());
258 public static void encodingError(Lexer lexer, short code, int c) {
261 if (lexer.configuration.ShowWarnings) {
264 if (code == WINDOWS_CHARS) {
265 lexer.badChars |= WINDOWS_CHARS;
267 Hashtable attributes = new Hashtable();
268 StringBuffer errorMessage =
269 new StringBuffer("Column " + lexer.columns + ": ");
270 MarkerUtilities.setLineNumber(attributes, lexer.lines);
271 // tidyPrint(lexer.errout, MessageFormat.format(res.getString("illegal_char"), new Object[] { new Integer(c)}));
273 MessageFormat.format(
274 res.getString("illegal_char"),
275 new Object[] { new Integer(c)}));
278 new Integer(IMarker.SEVERITY_ERROR));
279 attributes.put(JtidyPlugin.MARKER_NAME, Boolean.TRUE);
280 // attributes.put(IMarker.SEVERITY, new Integer(IMarker.SEVERITY_WARNING));
281 // attributes.put(IMarker.SEVERITY, new Integer(IMarker.SEVERITY_INFO));
283 MarkerUtilities.setMessage(
285 errorMessage.toString());
286 MarkerUtilities.createMarker(
290 } catch (CoreException e) {
292 } catch (MissingResourceException e) {
293 tidyPrintln(e.toString());
301 public static void entityError(
308 if (lexer.configuration.ShowWarnings) {
310 Hashtable attributes = new Hashtable();
311 StringBuffer errorMessage =
312 new StringBuffer("Column " + lexer.columns + ": ");
313 MarkerUtilities.setLineNumber(attributes, lexer.lines);
315 if (code == MISSING_SEMICOLON) {
317 // tidyPrint(lexer.errout, MessageFormat.format(res.getString("missing_semicolon"), new Object[] { entity }));
319 MessageFormat.format(
320 res.getString("missing_semicolon"),
321 new Object[] { entity }));
322 } catch (MissingResourceException e) {
323 tidyPrintln(e.toString());
325 } else if (code == UNKNOWN_ENTITY) {
327 // tidyPrint(lexer.errout, MessageFormat.format(res.getString("unknown_entity"), new Object[] { entity }));
329 MessageFormat.format(
330 res.getString("unknown_entity"),
331 new Object[] { entity }));
332 } catch (MissingResourceException e) {
333 tidyPrintln(e.toString());
335 } else if (code == UNESCAPED_AMPERSAND) {
337 // tidyPrint(lexer.errout, res.getString("unescaped_ampersand"));
338 errorMessage.append(res.getString("unescaped_ampersand"));
339 } catch (MissingResourceException e) {
340 tidyPrintln(e.toString());
345 new Integer(IMarker.SEVERITY_ERROR));
346 attributes.put(JtidyPlugin.MARKER_NAME, Boolean.TRUE);
347 // attributes.put(IMarker.SEVERITY, new Integer(IMarker.SEVERITY_WARNING));
348 // attributes.put(IMarker.SEVERITY, new Integer(IMarker.SEVERITY_INFO));
350 MarkerUtilities.setMessage(attributes, errorMessage.toString());
351 MarkerUtilities.createMarker(
355 } catch (CoreException e) {
361 public static void attrError(
368 /* keep quiet after 6 errors */
369 if (lexer.errors > 6)
372 Hashtable attributes = new Hashtable();
373 StringBuffer errorMessage =
374 new StringBuffer("Column " + lexer.columns + ": ");
376 if (lexer.configuration.ShowWarnings) {
377 /* on end of file adjust reported position to end of input */
378 if (code == UNEXPECTED_END_OF_FILE) {
379 lexer.lines = lexer.in.curline;
380 lexer.columns = lexer.in.curcol;
385 MarkerUtilities.setLineNumber(attributes, lexer.lines);
387 if (code == UNKNOWN_ATTRIBUTE) {
389 // tidyPrint(lexer.errout, MessageFormat.format(res.getString("unknown_attribute"), new Object[] { attr }));
391 MessageFormat.format(
392 res.getString("unknown_attribute"),
393 new Object[] { attr }));
394 } catch (MissingResourceException e) {
395 tidyPrintln(e.toString());
397 } else if (code == MISSING_ATTRIBUTE) {
399 // tidyPrint(lexer.errout, res.getString("warning"));
400 errorMessage.append(res.getString("warning"));
401 tag(errorMessage, node);
402 // tidyPrint(lexer.errout, MessageFormat.format(res.getString("missing_attribute"), new Object[] { attr }));
404 MessageFormat.format(
405 res.getString("missing_attribute"),
406 new Object[] { attr }));
407 } catch (MissingResourceException e) {
408 tidyPrintln(e.toString());
410 } else if (code == MISSING_ATTR_VALUE) {
412 // tidyPrint(lexer.errout, res.getString("warning"));
413 errorMessage.append(res.getString("warning"));
414 tag(errorMessage, node);
415 // tidyPrint(lexer.errout, MessageFormat.format(res.getString("missing_attr_value"), new Object[] { attr }));
417 MessageFormat.format(
418 res.getString("missing_attr_value"),
419 new Object[] { attr }));
420 } catch (MissingResourceException e) {
421 tidyPrintln(e.toString());
423 } else if (code == MISSING_IMAGEMAP) {
425 // tidyPrint(lexer.errout, res.getString("warning"));
426 errorMessage.append(res.getString("warning"));
427 tag(errorMessage, node);
428 // tidyPrint(lexer.errout, res.getString("missing_imagemap"));
429 errorMessage.append(res.getString("missing_imagemap"));
430 } catch (MissingResourceException e) {
431 tidyPrintln(e.toString());
433 lexer.badAccess |= MISSING_IMAGE_MAP;
434 } else if (code == BAD_ATTRIBUTE_VALUE) {
436 // tidyPrint(lexer.errout, res.getString("warning"));
437 errorMessage.append(res.getString("warning"));
438 tag(errorMessage, node);
439 // tidyPrint(lexer.errout, MessageFormat.format(res.getString("bad_attribute_value"), new Object[] { attr }));
441 MessageFormat.format(
442 res.getString("bad_attribute_value"),
443 new Object[] { attr }));
444 } catch (MissingResourceException e) {
445 tidyPrintln(e.toString());
447 } else if (code == XML_ATTRIBUTE_VALUE) {
449 // tidyPrint(lexer.errout, res.getString("warning"));
450 errorMessage.append(res.getString("warning"));
451 tag(errorMessage, node);
452 // tidyPrint(lexer.errout, MessageFormat.format(res.getString("xml_attribute_value"), new Object[] { attr }));
454 MessageFormat.format(
455 res.getString("xml_attribute_value"),
456 new Object[] { attr }));
457 } catch (MissingResourceException e) {
458 tidyPrintln(e.toString());
460 } else if (code == UNEXPECTED_GT) {
462 // tidyPrint(lexer.errout, res.getString("error"));
463 errorMessage.append(res.getString("error"));
464 tag(errorMessage, node);
465 // tidyPrint(lexer.errout, res.getString("unexpected_gt"));
466 errorMessage.append(res.getString("unexpected_gt"));
467 } catch (MissingResourceException e) {
468 tidyPrintln(e.toString());
472 } else if (code == UNEXPECTED_QUOTEMARK) {
474 // tidyPrint(lexer.errout, res.getString("warning"));
475 errorMessage.append(res.getString("warning"));
476 tag(errorMessage, node);
477 // tidyPrint(lexer.errout, res.getString("unexpected_quotemark"));
478 errorMessage.append(res.getString("unexpected_quotemark"));
479 } catch (MissingResourceException e) {
480 tidyPrintln(e.toString());
482 } else if (code == REPEATED_ATTRIBUTE) {
484 // tidyPrint(lexer.errout, res.getString("warning"));
485 errorMessage.append(res.getString("warning"));
486 tag(errorMessage, node);
487 // tidyPrint(lexer.errout, res.getString("repeated_attribute"));
488 errorMessage.append(res.getString("repeated_attribute"));
489 } catch (MissingResourceException e) {
490 tidyPrintln(e.toString());
492 } else if (code == PROPRIETARY_ATTR_VALUE) {
494 // tidyPrint(lexer.errout, res.getString("warning"));
495 errorMessage.append(res.getString("warning"));
496 tag(errorMessage, node);
497 // tidyPrint(lexer.errout, MessageFormat.format(res.getString("proprietary_attr_value"), new Object[] { attr }));
499 MessageFormat.format(
500 res.getString("proprietary_attr_value"),
501 new Object[] { attr }));
502 } catch (MissingResourceException e) {
503 tidyPrintln(e.toString());
505 } else if (code == UNEXPECTED_END_OF_FILE) {
507 // tidyPrint(lexer.errout, res.getString("unexpected_end_of_file"));
509 res.getString("unexpected_end_of_file"));
510 } catch (MissingResourceException e) {
511 tidyPrintln(e.toString());
513 } else if (code == ID_NAME_MISMATCH) {
515 // tidyPrint(lexer.errout, res.getString("warning"));
516 errorMessage.append(res.getString("warning"));
517 tag(errorMessage, node);
518 // tidyPrint(lexer.errout, res.getString("id_name_mismatch"));
519 errorMessage.append(res.getString("id_name_mismatch"));
520 } catch (MissingResourceException e) {
521 tidyPrintln(e.toString());
525 // attributes.put(IMarker.SEVERITY, new Integer(IMarker.SEVERITY_ERROR));
528 new Integer(IMarker.SEVERITY_WARNING));
529 // attributes.put(IMarker.SEVERITY, new Integer(IMarker.SEVERITY_INFO));
530 attributes.put(JtidyPlugin.MARKER_NAME, Boolean.TRUE);
532 MarkerUtilities.setMessage(attributes, errorMessage.toString());
533 MarkerUtilities.createMarker(
537 } catch (CoreException e) {
540 } else if (code == UNEXPECTED_GT) {
542 MarkerUtilities.setLineNumber(attributes, lexer.lines);
544 // tidyPrint(lexer.errout, res.getString("error"));
545 errorMessage.append(res.getString("error"));
546 tag(errorMessage, node);
547 // tidyPrint(lexer.errout, res.getString("unexpected_gt"));
548 errorMessage.append(res.getString("unexpected_gt"));
551 new Integer(IMarker.SEVERITY_ERROR));
552 // attributes.put(IMarker.SEVERITY, new Integer(IMarker.SEVERITY_WARNING));
553 // attributes.put(IMarker.SEVERITY, new Integer(IMarker.SEVERITY_INFO));
554 attributes.put(JtidyPlugin.MARKER_NAME, Boolean.TRUE);
556 MarkerUtilities.setMessage(
558 errorMessage.toString());
559 MarkerUtilities.createMarker(
563 } catch (CoreException e) {
565 } catch (MissingResourceException e) {
566 tidyPrintln(e.toString());
575 public static void warning(
582 TagTable tt = lexer.configuration.tt;
586 /* keep quiet after 6 errors */
587 if (lexer.errors > 6)
590 if (lexer.configuration.ShowWarnings) {
592 /* on end of file adjust reported position to end of input */
593 if (code == UNEXPECTED_END_OF_FILE) {
594 lexer.lines = lexer.in.curline;
595 lexer.columns = lexer.in.curcol;
599 Hashtable attributes = new Hashtable();
600 StringBuffer errorMessage =
601 new StringBuffer("Column " + lexer.columns + ": ");
603 MarkerUtilities.setLineNumber(attributes, lexer.lines);
605 if (code == MISSING_ENDTAG_FOR) {
607 // tidyPrint(lexer.errout, MessageFormat.format(res.getString("missing_endtag_for"), new Object[] { element.element }));
609 MessageFormat.format(
610 res.getString("missing_endtag_for"),
611 new Object[] { element.element }));
612 } catch (MissingResourceException e) {
613 tidyPrintln(e.toString());
615 } else if (code == MISSING_ENDTAG_BEFORE) {
617 // tidyPrint(lexer.errout, MessageFormat.format(res.getString("missing_endtag_before"), new Object[] { element.element }));
619 MessageFormat.format(
620 res.getString("missing_endtag_before"),
621 new Object[] { element.element }));
623 } catch (MissingResourceException e) {
624 tidyPrintln(e.toString());
626 tag(errorMessage, node);
627 } else if (code == DISCARDING_UNEXPECTED) {
628 //REVISIT: DIscarding... message
631 // // tidyPrint(lexer.errout, res.getString("discarding_unexpected"));
632 // errorMessage.append(res.getString("discarding_unexpected"));
633 // } catch (MissingResourceException e) {
634 // tidyPrintln(e.toString());
636 // tag(errorMessage, lexer, node);
637 } else if (code == NESTED_EMPHASIS) {
639 // tidyPrint(lexer.errout, res.getString("nested_emphasis"));
640 errorMessage.append(res.getString("nested_emphasis"));
641 } catch (MissingResourceException e) {
642 tidyPrintln(e.toString());
644 tag(errorMessage, node);
645 } else if (code == COERCE_TO_ENDTAG) {
647 // tidyPrint(lexer.errout, MessageFormat.format(res.getString("coerce_to_endtag"), new Object[] { element.element }));
649 MessageFormat.format(
650 res.getString("coerce_to_endtag"),
651 new Object[] { element.element }));
652 } catch (MissingResourceException e) {
653 tidyPrintln(e.toString());
655 } else if (code == NON_MATCHING_ENDTAG) {
657 // tidyPrint(lexer.errout, res.getString("non_matching_endtag_1"));
658 errorMessage.append(res.getString("non_matching_endtag_1"));
659 } catch (MissingResourceException e) {
660 tidyPrintln(e.toString());
662 tag(errorMessage, node);
664 // tidyPrint(lexer.errout, MessageFormat.format(res.getString("non_matching_endtag_2"), new Object[] { element.element }));
666 MessageFormat.format(
667 res.getString("non_matching_endtag_2"),
668 new Object[] { element.element }));
669 } catch (MissingResourceException e) {
670 tidyPrintln(e.toString());
672 } else if (code == TAG_NOT_ALLOWED_IN) {
674 // tidyPrint(lexer.errout, res.getString("warning"));
675 errorMessage.append(res.getString("warning"));
676 } catch (MissingResourceException e) {
677 tidyPrintln(e.toString());
679 tag(errorMessage, node);
681 // tidyPrint(lexer.errout, MessageFormat.format(res.getString("tag_not_allowed_in"), new Object[] { element.element }));
683 MessageFormat.format(
684 res.getString("tag_not_allowed_in"),
685 new Object[] { element.element }));
686 } catch (MissingResourceException e) {
687 tidyPrintln(e.toString());
689 } else if (code == DOCTYPE_AFTER_TAGS) {
691 // tidyPrint(lexer.errout, res.getString("doctype_after_tags"));
692 errorMessage.append(res.getString("doctype_after_tags"));
693 } catch (MissingResourceException e) {
694 tidyPrintln(e.toString());
696 } else if (code == MISSING_STARTTAG) {
698 // tidyPrint(lexer.errout, MessageFormat.format(res.getString("missing_starttag"), new Object[] { node.element }));
700 MessageFormat.format(
701 res.getString("missing_starttag"),
702 new Object[] { node.element }));
703 } catch (MissingResourceException e) {
704 tidyPrintln(e.toString());
706 } else if (code == UNEXPECTED_ENDTAG) {
708 // tidyPrint(lexer.errout, MessageFormat.format(res.getString("unexpected_endtag"), new Object[] { node.element }));
712 // MessageFormat.format(res.getString("unexpected_endtag_suffix"), new Object[] { element.element }));
714 MessageFormat.format(
715 res.getString("unexpected_endtag"),
716 new Object[] { node.element }));
717 } catch (MissingResourceException e) {
718 tidyPrintln(e.toString());
720 } else if (code == TOO_MANY_ELEMENTS) {
722 // tidyPrint(lexer.errout, MessageFormat.format(res.getString("too_many_elements"), new Object[] { node.element }));
726 // MessageFormat.format(res.getString("too_many_elements_suffix"), new Object[] { element.element }));
728 MessageFormat.format(
729 res.getString("too_many_elements"),
730 new Object[] { node.element }));
731 } catch (MissingResourceException e) {
732 tidyPrintln(e.toString());
734 } else if (code == USING_BR_INPLACE_OF) {
736 // tidyPrint(lexer.errout, res.getString("using_br_inplace_of"));
737 errorMessage.append(res.getString("using_br_inplace_of"));
738 } catch (MissingResourceException e) {
739 tidyPrintln(e.toString());
741 tag(errorMessage, node);
742 } else if (code == INSERTING_TAG) {
744 // tidyPrint(lexer.errout, MessageFormat.format(res.getString("inserting_tag"), new Object[] { node.element }));
746 MessageFormat.format(
747 res.getString("inserting_tag"),
748 new Object[] { node.element }));
749 } catch (MissingResourceException e) {
750 tidyPrintln(e.toString());
752 } else if (code == CANT_BE_NESTED) {
754 // tidyPrint(lexer.errout, res.getString("warning"));
755 errorMessage.append(res.getString("warning"));
756 } catch (MissingResourceException e) {
757 tidyPrintln(e.toString());
759 tag(errorMessage, node);
761 // tidyPrint(lexer.errout, res.getString("cant_be_nested"));
762 errorMessage.append(res.getString("cant_be_nested"));
763 } catch (MissingResourceException e) {
764 tidyPrintln(e.toString());
766 } else if (code == PROPRIETARY_ELEMENT) {
768 // tidyPrint(lexer.errout, res.getString("warning"));
769 errorMessage.append(res.getString("warning"));
770 } catch (MissingResourceException e) {
771 tidyPrintln(e.toString());
773 tag(errorMessage, node);
775 // tidyPrint(lexer.errout, res.getString("proprietary_element"));
776 errorMessage.append(res.getString("proprietary_element"));
777 } catch (MissingResourceException e) {
778 tidyPrintln(e.toString());
781 if (node.tag == tt.tagLayer)
782 lexer.badLayout |= USING_LAYER;
783 else if (node.tag == tt.tagSpacer)
784 lexer.badLayout |= USING_SPACER;
785 else if (node.tag == tt.tagNobr)
786 lexer.badLayout |= USING_NOBR;
787 } else if (code == OBSOLETE_ELEMENT) {
789 if (element.tag != null
790 && (element.tag.model & Dict.CM_OBSOLETE) != 0) {
791 // tidyPrint(lexer.errout, res.getString("obsolete_element"));
792 errorMessage.append(res.getString("obsolete_element"));
794 // tidyPrint(lexer.errout, res.getString("replacing_element"));
795 errorMessage.append(res.getString("replacing_element"));
798 } catch (MissingResourceException e) {
799 tidyPrintln(e.toString());
801 tag(errorMessage, element);
803 // tidyPrint(lexer.errout, res.getString("by"));
804 errorMessage.append(res.getString("by"));
805 } catch (MissingResourceException e) {
806 tidyPrintln(e.toString());
808 tag(errorMessage, node);
809 } else if (code == TRIM_EMPTY_ELEMENT) {
811 // tidyPrint(lexer.errout, res.getString("trim_empty_element"));
812 errorMessage.append(res.getString("trim_empty_element"));
813 } catch (MissingResourceException e) {
814 tidyPrintln(e.toString());
816 tag(errorMessage, element);
817 } else if (code == MISSING_TITLE_ELEMENT) {
819 // tidyPrint(lexer.errout, res.getString("missing_title_element"));
820 errorMessage.append(res.getString("missing_title_element"));
821 } catch (MissingResourceException e) {
822 tidyPrintln(e.toString());
824 } else if (code == ILLEGAL_NESTING) {
826 // tidyPrint(lexer.errout, res.getString("warning"));
827 errorMessage.append(res.getString("warning"));
828 } catch (MissingResourceException e) {
829 tidyPrintln(e.toString());
831 tag(errorMessage, element);
833 // tidyPrint(lexer.errout, res.getString("illegal_nesting"));
834 errorMessage.append(res.getString("illegal_nesting"));
835 } catch (MissingResourceException e) {
836 tidyPrintln(e.toString());
838 } else if (code == NOFRAMES_CONTENT) {
840 // tidyPrint(lexer.errout, res.getString("warning"));
841 errorMessage.append(res.getString("warning"));
842 } catch (MissingResourceException e) {
843 tidyPrintln(e.toString());
845 tag(errorMessage, node);
847 // tidyPrint(lexer.errout, res.getString("noframes_content"));
848 errorMessage.append(res.getString("noframes_content"));
849 } catch (MissingResourceException e) {
850 tidyPrintln(e.toString());
852 } else if (code == INCONSISTENT_VERSION) {
854 // tidyPrint(lexer.errout, res.getString("inconsistent_version"));
855 errorMessage.append(res.getString("inconsistent_version"));
856 } catch (MissingResourceException e) {
857 tidyPrintln(e.toString());
859 } else if (code == MALFORMED_DOCTYPE) {
861 // tidyPrint(lexer.errout, res.getString("malformed_doctype"));
862 errorMessage.append(res.getString("malformed_doctype"));
863 } catch (MissingResourceException e) {
864 tidyPrintln(e.toString());
866 } else if (code == CONTENT_AFTER_BODY) {
868 // tidyPrint(lexer.errout, res.getString("content_after_body"));
869 errorMessage.append(res.getString("content_after_body"));
870 } catch (MissingResourceException e) {
871 tidyPrintln(e.toString());
873 } else if (code == MALFORMED_COMMENT) {
875 // tidyPrint(lexer.errout, res.getString("malformed_comment"));
876 errorMessage.append(res.getString("malformed_comment"));
877 } catch (MissingResourceException e) {
878 tidyPrintln(e.toString());
880 } else if (code == BAD_COMMENT_CHARS) {
882 // tidyPrint(lexer.errout, res.getString("bad_comment_chars"));
883 errorMessage.append(res.getString("bad_comment_chars"));
884 } catch (MissingResourceException e) {
885 tidyPrintln(e.toString());
887 } else if (code == BAD_XML_COMMENT) {
889 // tidyPrint(lexer.errout, res.getString("bad_xml_comment"));
890 errorMessage.append(res.getString("bad_xml_comment"));
891 } catch (MissingResourceException e) {
892 tidyPrintln(e.toString());
894 } else if (code == BAD_CDATA_CONTENT) {
896 // tidyPrint(lexer.errout, res.getString("bad_cdata_content"));
897 errorMessage.append(res.getString("bad_cdata_content"));
898 } catch (MissingResourceException e) {
899 tidyPrintln(e.toString());
901 } else if (code == INCONSISTENT_NAMESPACE) {
903 // tidyPrint(lexer.errout, res.getString("inconsistent_namespace"));
905 res.getString("inconsistent_namespace"));
906 } catch (MissingResourceException e) {
907 tidyPrintln(e.toString());
909 } else if (code == DTYPE_NOT_UPPER_CASE) {
911 // tidyPrint(lexer.errout, res.getString("dtype_not_upper_case"));
912 errorMessage.append(res.getString("dtype_not_upper_case"));
913 } catch (MissingResourceException e) {
914 tidyPrintln(e.toString());
916 } else if (code == UNEXPECTED_END_OF_FILE) {
918 // tidyPrint(lexer.errout, res.getString("unexpected_end_of_file"));
920 res.getString("unexpected_end_of_file"));
921 } catch (MissingResourceException e) {
922 tidyPrintln(e.toString());
924 tag(errorMessage, element);
926 // attributes.put(IMarker.SEVERITY, new Integer(IMarker.SEVERITY_ERROR));
929 new Integer(IMarker.SEVERITY_WARNING));
930 attributes.put(JtidyPlugin.MARKER_NAME, Boolean.TRUE);
931 // attributes.put(IMarker.SEVERITY, new Integer(IMarker.SEVERITY_INFO));
933 MarkerUtilities.setMessage(attributes, errorMessage.toString());
934 MarkerUtilities.createMarker(
938 } catch (CoreException e) {
944 public static void error(
951 /* keep quiet after 6 errors */
952 if (lexer.errors > 6)
959 Hashtable attributes = new Hashtable();
960 StringBuffer errorMessage =
961 new StringBuffer("Column " + lexer.columns + ": ");
963 MarkerUtilities.setLineNumber(attributes, lexer.lines);
965 if (code == SUSPECTED_MISSING_QUOTE) {
967 // tidyPrint(lexer.errout, res.getString("suspected_missing_quote"));
968 errorMessage.append(res.getString("suspected_missing_quote"));
970 } catch (MissingResourceException e) {
971 tidyPrintln(e.toString());
973 } else if (code == DUPLICATE_FRAMESET) {
975 // tidyPrint(lexer.errout, res.getString("duplicate_frameset"));
976 errorMessage.append(res.getString("duplicate_frameset"));
977 } catch (MissingResourceException e) {
978 tidyPrintln(e.toString());
980 } else if (code == UNKNOWN_ELEMENT) {
982 // tidyPrint(lexer.errout, res.getString("error"));
983 errorMessage.append(res.getString("error"));
984 } catch (MissingResourceException e) {
985 tidyPrintln(e.toString());
987 tag(errorMessage, node);
989 // tidyPrint(lexer.errout, res.getString("unknown_element"));
990 errorMessage.append(res.getString("unknown_element"));
991 } catch (MissingResourceException e) {
992 tidyPrintln(e.toString());
994 } else if (code == UNEXPECTED_ENDTAG) {
996 // tidyPrint(lexer.errout, MessageFormat.format(res.getString("unexpected_endtag"), new Object[] { node.element }));
998 MessageFormat.format(
999 res.getString("unexpected_endtag"),
1000 new Object[] { node.element }));
1001 if (element != null) {
1004 // MessageFormat.format(res.getString("unexpected_endtag_suffix"), new Object[] { element.element }));
1005 // errorMessage.append(MessageFormat.format(res.getString("unexpected_endtag_suffix"), new Object[] { element.element }));
1007 } catch (MissingResourceException e) {
1008 tidyPrintln(e.toString());
1011 attributes.put(IMarker.SEVERITY, new Integer(IMarker.SEVERITY_ERROR));
1012 // attributes.put(IMarker.SEVERITY, new Integer(IMarker.SEVERITY_WARNING));
1013 // attributes.put(IMarker.SEVERITY, new Integer(IMarker.SEVERITY_INFO));
1014 attributes.put(JtidyPlugin.MARKER_NAME, Boolean.TRUE);
1016 MarkerUtilities.setMessage(attributes, errorMessage.toString());
1017 MarkerUtilities.createMarker(
1021 } catch (CoreException e) {
1023 // tidyPrintln(lexer.errout);
1026 public static void errorSummary(Lexer lexer) {
1027 /* adjust badAccess to that its null if frames are ok */
1028 if ((lexer.badAccess & (USING_FRAMES | USING_NOFRAMES)) != 0) {
1029 if (!(((lexer.badAccess & USING_FRAMES) != 0)
1030 && ((lexer.badAccess & USING_NOFRAMES) == 0)))
1031 lexer.badAccess &= ~(USING_FRAMES | USING_NOFRAMES);
1034 Hashtable attributes = new Hashtable();
1035 StringBuffer errorMessage =
1036 new StringBuffer("Column " + lexer.columns + ": ");
1038 MarkerUtilities.setLineNumber(attributes, lexer.lines);
1040 if (lexer.badChars != 0) {
1041 if ((lexer.badChars & WINDOWS_CHARS) != 0) {
1043 // tidyPrint(lexer.errout, res.getString("badchars_summary"));
1044 errorMessage.append(res.getString("badchars_summary"));
1045 } catch (MissingResourceException e) {
1046 tidyPrintln(e.toString());
1051 if (lexer.badForm != 0) {
1053 // tidyPrint(lexer.errout, res.getString("badform_summary"));
1054 errorMessage.append(res.getString("badform_summary"));
1055 } catch (MissingResourceException e) {
1056 tidyPrintln(e.toString());
1060 if (lexer.badAccess != 0) {
1061 if ((lexer.badAccess & MISSING_SUMMARY) != 0) {
1063 // tidyPrint(lexer.errout, res.getString("badaccess_missing_summary"));
1064 errorMessage.append(
1065 res.getString("badaccess_missing_summary"));
1066 } catch (MissingResourceException e) {
1067 tidyPrintln(e.toString());
1071 if ((lexer.badAccess & MISSING_IMAGE_ALT) != 0) {
1073 // tidyPrint(lexer.errout, res.getString("badaccess_missing_image_alt"));
1074 errorMessage.append(
1075 res.getString("badaccess_missing_image_alt"));
1076 } catch (MissingResourceException e) {
1077 tidyPrintln(e.toString());
1081 if ((lexer.badAccess & MISSING_IMAGE_MAP) != 0) {
1083 // tidyPrint(lexer.errout, res.getString("badaccess_missing_image_map"));
1084 errorMessage.append(
1085 res.getString("badaccess_missing_image_map"));
1086 } catch (MissingResourceException e) {
1087 tidyPrintln(e.toString());
1091 if ((lexer.badAccess & MISSING_LINK_ALT) != 0) {
1093 // tidyPrint(lexer.errout, res.getString("badaccess_missing_link_alt"));
1094 errorMessage.append(
1095 res.getString("badaccess_missing_link_alt"));
1096 } catch (MissingResourceException e) {
1097 tidyPrintln(e.toString());
1101 if (((lexer.badAccess & USING_FRAMES) != 0)
1102 && ((lexer.badAccess & USING_NOFRAMES) == 0)) {
1104 // tidyPrint(lexer.errout, res.getString("badaccess_frames"));
1105 errorMessage.append(res.getString("badaccess_frames"));
1106 } catch (MissingResourceException e) {
1107 tidyPrintln(e.toString());
1112 // tidyPrint(lexer.errout, MessageFormat.format(res.getString("badaccess_summary"), new Object[] { ACCESS_URL }));
1113 errorMessage.append(
1114 MessageFormat.format(
1115 res.getString("badaccess_summary"),
1116 new Object[] { ACCESS_URL }));
1117 } catch (MissingResourceException e) {
1118 tidyPrintln(e.toString());
1122 if (lexer.badLayout != 0) {
1123 if ((lexer.badLayout & USING_LAYER) != 0) {
1125 // tidyPrint(lexer.errout, res.getString("badlayout_using_layer"));
1126 errorMessage.append(res.getString("badlayout_using_layer"));
1127 } catch (MissingResourceException e) {
1128 tidyPrintln(e.toString());
1132 if ((lexer.badLayout & USING_SPACER) != 0) {
1134 // tidyPrint(lexer.errout, res.getString("badlayout_using_spacer"));
1135 errorMessage.append(
1136 res.getString("badlayout_using_spacer"));
1137 } catch (MissingResourceException e) {
1138 tidyPrintln(e.toString());
1142 if ((lexer.badLayout & USING_FONT) != 0) {
1144 // tidyPrint(lexer.errout, res.getString("badlayout_using_font"));
1145 errorMessage.append(res.getString("badlayout_using_font"));
1146 } catch (MissingResourceException e) {
1147 tidyPrintln(e.toString());
1151 if ((lexer.badLayout & USING_NOBR) != 0) {
1153 // tidyPrint(lexer.errout, res.getString("badlayout_using_nobr"));
1154 errorMessage.append(res.getString("badlayout_using_nobr"));
1155 } catch (MissingResourceException e) {
1156 tidyPrintln(e.toString());
1160 if ((lexer.badLayout & USING_BODY) != 0) {
1162 // tidyPrint(lexer.errout, res.getString("badlayout_using_body"));
1163 errorMessage.append(res.getString("badlayout_using_body"));
1164 } catch (MissingResourceException e) {
1165 tidyPrintln(e.toString());
1170 new Integer(IMarker.SEVERITY_ERROR));
1171 // attributes.put(IMarker.SEVERITY, new Integer(IMarker.SEVERITY_WARNING));
1172 // attributes.put(IMarker.SEVERITY, new Integer(IMarker.SEVERITY_INFO));
1173 attributes.put(JtidyPlugin.MARKER_NAME, Boolean.TRUE);
1175 MarkerUtilities.setMessage(attributes, errorMessage.toString());
1176 MarkerUtilities.createMarker(
1180 } catch (CoreException e) {
1185 public static void unknownOption(PrintWriter errout, char c) {
1188 MessageFormat.format(
1189 res.getString("unrecognized_option"),
1190 new Object[] { new String(new char[] { c })
1192 } catch (MissingResourceException e) {
1193 tidyPrintln(e.toString());
1197 public static void unknownFile(
1203 MessageFormat.format(
1204 res.getString("unknown_file"),
1205 new Object[] { program, file }));
1206 } catch (MissingResourceException e) {
1207 tidyPrintln(e.toString());
1211 public static void needsAuthorIntervention(PrintWriter errout) {
1213 tidyPrintln(res.getString("needs_author_intervention"));
1214 } catch (MissingResourceException e) {
1215 tidyPrintln(e.toString());
1219 public static void missingBody(PrintWriter errout) {
1221 tidyPrintln(res.getString("missing_body"));
1222 } catch (MissingResourceException e) {
1223 tidyPrintln(e.toString());
1227 public static void reportNumberOfSlides(PrintWriter errout, int count) {
1230 MessageFormat.format(
1231 res.getString("slides_found"),
1232 new Object[] { new Integer(count)}));
1233 } catch (MissingResourceException e) {
1234 tidyPrintln(e.toString());
1238 public static void generalInfo(PrintWriter errout) {
1240 tidyPrintln(res.getString("general_info"));
1241 } catch (MissingResourceException e) {
1242 tidyPrintln(e.toString());
1246 public static void helloMessage(
1250 currentFile = filename; /* for use with Gnu Emacs */
1254 MessageFormat.format(
1255 res.getString("hello_message"),
1256 new Object[] { date, filename }));
1257 } catch (MissingResourceException e) {
1258 tidyPrintln(e.toString());
1262 public static void reportVersion(
1269 String vers = lexer.HTMLVersionName();
1270 MutableInteger cc = new MutableInteger();
1273 if (doctype != null) {
1275 MessageFormat.format(
1276 res.getString("doctype_given"),
1277 new Object[] { filename }));
1278 StringBuffer buf = new StringBuffer();
1279 for (i = doctype.start; i < doctype.end; ++i) {
1280 c = (int) doctype.textarray[i];
1282 /* look for UTF-8 multibyte character */
1284 i += PPrint.getUTF8(doctype.textarray, i, cc);
1288 if (c == (char) '"')
1290 else if (state == 1) {
1292 // tidyPrint((char) c);
1298 tidyPrint( buf.toString() );
1302 MessageFormat.format(
1303 res.getString("report_version"),
1306 (vers != null ? vers : "HTML proprietary")}));
1307 } catch (MissingResourceException e) {
1308 tidyPrintln(e.toString());
1312 public static void reportNumWarnings(PrintWriter errout, Lexer lexer) {
1313 if (lexer.warnings > 0) {
1316 MessageFormat.format(
1317 res.getString("num_warnings"),
1318 new Object[] { new Integer(lexer.warnings)}));
1319 } catch (MissingResourceException e) {
1320 tidyPrintln(e.toString());
1324 tidyPrintln(res.getString("no_warnings"));
1325 } catch (MissingResourceException e) {
1326 tidyPrintln(e.toString());
1331 public static void helpText(PrintWriter out, String prog) {
1334 MessageFormat.format(
1335 res.getString("help_text"),
1336 new Object[] { prog, RELEASE_DATE }));
1337 } catch (MissingResourceException e) {
1338 tidyPrintln(e.toString());
1342 public static void badTree(PrintWriter errout) {
1344 tidyPrintln(res.getString("bad_tree"));
1345 } catch (MissingResourceException e) {
1346 tidyPrintln(e.toString());