Switched to Eclipse 2.1 development
[phpeclipse.git] / archive / net.sourceforge.phpeclipse.jtidy / src / net / sourceforge / phpdt / tidy / w3c / Report.java
1 /*
2  * @(#)Report.java   1.11 2000/08/16
3  *
4  */
5
6 package net.sourceforge.phpdt.tidy.w3c;
7
8 /**
9  *
10  * Error/informational message reporter.
11  *
12  * You should only need to edit the file TidyMessages.properties
13  * to localize HTML tidy.
14  *
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>
18  *
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
34  */
35
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;
41
42 import net.sourceforge.phpdt.tidy.JTidyConsole;
43 import net.sourceforge.phpdt.tidy.JtidyPlugin;
44
45 import org.eclipse.core.resources.IMarker;
46 import org.eclipse.core.runtime.CoreException;
47 import org.eclipse.ui.texteditor.MarkerUtilities;
48
49 public class Report {
50
51         /* used to point to Web Accessibility Guidelines */
52         public static final String ACCESS_URL = "http://www.w3.org/WAI/GL";
53
54         public static final String RELEASE_DATE = "4th August 2000";
55
56         public static String currentFile;
57         /* sasdjb 01May00 for GNU Emacs error parsing */
58
59         /* error codes for entities */
60
61         public static final short MISSING_SEMICOLON = 1;
62         public static final short UNKNOWN_ENTITY = 2;
63         public static final short UNESCAPED_AMPERSAND = 3;
64
65         /* error codes for element messages */
66
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;
100
101         /* error codes used for attribute messages */
102
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;
114
115         /* accessibility flaws */
116
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;
123
124         /* presentation flaws */
125
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;
131
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;
136
137         private static short optionerrors;
138
139         private static ResourceBundle res = null;
140
141         static {
142                 try { 
143                         res = ResourceBundle.getBundle("net/sourceforge/phpdt/tidy/w3c/TidyMessages");
144                 } catch (MissingResourceException e) {
145                         throw new Error(e.toString());
146                 }
147         }
148
149         //  public static void tidyPrint(PrintWriter p, String msg) {
150         //    p.print(msg);
151         //  }
152
153 //      public static void tidyPrint(char c) {
154 //              // p.println(msg);
155 //      //      JTidyConsole.print(new String(c));
156 //      }
157         
158         public static void tidyPrint(String msg) {
159                 // p.println(msg);
160                 JTidyConsole.print(msg);
161         }
162
163         public static void tidyPrintln(String msg) {
164                 // p.println(msg);
165                 JTidyConsole.println(msg);
166         }
167
168         public static void tidyPrintln() {
169                 JTidyConsole.println("");
170         }
171
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");
175         }
176
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");
187         //      else
188         //        tidyPrint(lexer.errout, tag.element);
189         //    }
190         //  }
191
192         public static void tag(StringBuffer errorMessage, Node tag) {
193                 if (tag != null) {
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");
206                         } else {
207                                 //     tidyPrint(lexer.errout, tag.element);
208                                 errorMessage.append(tag.element);
209                         }
210                 }
211         }
212
213         /* lexer is not defined when this is called */
214         public static void unknownOption(String option) {
215                 optionerrors++;
216                 try {
217                         System.err.println(
218                                 MessageFormat.format(
219                                         res.getString("unknown_option"),
220                                         new Object[] { option }));
221                 } catch (MissingResourceException e) {
222                         System.err.println(e.toString());
223                 }
224         }
225
226         /* lexer is not defined when this is called */
227         public static void badArgument(String option) {
228                 optionerrors++;
229                 try {
230                         System.err.println(
231                                 MessageFormat.format(
232                                         res.getString("bad_argument"),
233                                         new Object[] { option }));
234                 } catch (MissingResourceException e) {
235                         System.err.println(e.toString());
236                 }
237         }
238
239         //  public static void position(Lexer lexer) {
240         //    try {
241         //      /* Change formatting to be parsable by GNU Emacs */
242         //      if (lexer.configuration.Emacs) {
243         //        tidyPrint(
244         //          lexer.errout,
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 */ {
250         //        tidyPrint(
251         //          lexer.errout,
252         //          MessageFormat.format(res.getString("line_column"), new Object[] { new Integer(lexer.lines), new Integer(lexer.columns)}));
253         //      }
254         //    } catch (MissingResourceException e) {
255         //      lexer.errout.tidyPrintln(e.toString());
256         //    }
257         //  }
258
259         public static void encodingError(Lexer lexer, short code, int c) {
260                 lexer.warnings++;
261
262                 if (lexer.configuration.ShowWarnings) {
263                         //    position(lexer);
264
265                         if (code == WINDOWS_CHARS) {
266                                 lexer.badChars |= WINDOWS_CHARS;
267                                 try {
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)}));
273                                         errorMessage.append(
274                                                 MessageFormat.format(
275                                                         res.getString("illegal_char"),
276                                                         new Object[] { new Integer(c)}));
277                                         attributes.put(
278                                                 IMarker.SEVERITY,
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));
283                                         try {
284                                                 MarkerUtilities.setMessage(
285                                                         attributes,
286                                                         errorMessage.toString());
287                                                 MarkerUtilities.createMarker(
288                                                         lexer.getIFile(),
289                                                         attributes,
290                                                         IMarker.PROBLEM);
291                                         } catch (CoreException e) {
292                                         }
293                                 } catch (MissingResourceException e) {
294                                         tidyPrintln(e.toString());
295                                 }
296                         }
297
298                         tidyPrintln();
299                 }
300         }
301
302         public static void entityError(
303                 Lexer lexer,
304                 short code,
305                 String entity,
306                 int c) {
307                 lexer.warnings++;
308
309                 if (lexer.configuration.ShowWarnings) {
310                         //  position(lexer);
311                         Hashtable attributes = new Hashtable();
312                         StringBuffer errorMessage =
313                                 new StringBuffer("Column " + lexer.columns + ": ");
314                         MarkerUtilities.setLineNumber(attributes, lexer.lines);
315
316                         if (code == MISSING_SEMICOLON) {
317                                 try {
318                                         // tidyPrint(lexer.errout, MessageFormat.format(res.getString("missing_semicolon"), new Object[] { entity }));
319                                         errorMessage.append(
320                                                 MessageFormat.format(
321                                                         res.getString("missing_semicolon"),
322                                                         new Object[] { entity }));
323                                 } catch (MissingResourceException e) {
324                                         tidyPrintln(e.toString());
325                                 }
326                         } else if (code == UNKNOWN_ENTITY) {
327                                 try {
328                                         // tidyPrint(lexer.errout, MessageFormat.format(res.getString("unknown_entity"), new Object[] { entity }));
329                                         errorMessage.append(
330                                                 MessageFormat.format(
331                                                         res.getString("unknown_entity"),
332                                                         new Object[] { entity }));
333                                 } catch (MissingResourceException e) {
334                                         tidyPrintln(e.toString());
335                                 }
336                         } else if (code == UNESCAPED_AMPERSAND) {
337                                 try {
338                                         // tidyPrint(lexer.errout, res.getString("unescaped_ampersand"));
339                                         errorMessage.append(res.getString("unescaped_ampersand"));
340                                 } catch (MissingResourceException e) {
341                                         tidyPrintln(e.toString());
342                                 }
343                         }
344                         attributes.put(
345                                 IMarker.SEVERITY,
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));
350                         try {
351                                 MarkerUtilities.setMessage(attributes, errorMessage.toString());
352                                 MarkerUtilities.createMarker(
353                                         lexer.getIFile(),
354                                         attributes,
355                                         IMarker.PROBLEM);
356                         } catch (CoreException e) {
357                         }
358                         tidyPrintln();
359                 }
360         }
361
362         public static void attrError(
363                 Lexer lexer,
364                 Node node,
365                 String attr,
366                 short code) {
367                 lexer.warnings++;
368
369                 /* keep quiet after 6 errors */
370                 if (lexer.errors > 6)
371                         return;
372
373                 Hashtable attributes = new Hashtable();
374                 StringBuffer errorMessage =
375                         new StringBuffer("Column " + lexer.columns + ": ");
376
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;
382                         }
383
384                         //  position(lexer);
385
386                         MarkerUtilities.setLineNumber(attributes, lexer.lines);
387
388                         if (code == UNKNOWN_ATTRIBUTE) {
389                                 try {
390                                         // tidyPrint(lexer.errout, MessageFormat.format(res.getString("unknown_attribute"), new Object[] { attr }));
391                                         errorMessage.append(
392                                                 MessageFormat.format(
393                                                         res.getString("unknown_attribute"),
394                                                         new Object[] { attr }));
395                                 } catch (MissingResourceException e) {
396                                         tidyPrintln(e.toString());
397                                 }
398                         } else if (code == MISSING_ATTRIBUTE) {
399                                 try {
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 }));
404                                         errorMessage.append(
405                                                 MessageFormat.format(
406                                                         res.getString("missing_attribute"),
407                                                         new Object[] { attr }));
408                                 } catch (MissingResourceException e) {
409                                         tidyPrintln(e.toString());
410                                 }
411                         } else if (code == MISSING_ATTR_VALUE) {
412                                 try {
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 }));
417                                         errorMessage.append(
418                                                 MessageFormat.format(
419                                                         res.getString("missing_attr_value"),
420                                                         new Object[] { attr }));
421                                 } catch (MissingResourceException e) {
422                                         tidyPrintln(e.toString());
423                                 }
424                         } else if (code == MISSING_IMAGEMAP) {
425                                 try {
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());
433                                 }
434                                 lexer.badAccess |= MISSING_IMAGE_MAP;
435                         } else if (code == BAD_ATTRIBUTE_VALUE) {
436                                 try {
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 }));
441                                         errorMessage.append(
442                                                 MessageFormat.format(
443                                                         res.getString("bad_attribute_value"),
444                                                         new Object[] { attr }));
445                                 } catch (MissingResourceException e) {
446                                         tidyPrintln(e.toString());
447                                 }
448                         } else if (code == XML_ATTRIBUTE_VALUE) {
449                                 try {
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 }));
454                                         errorMessage.append(
455                                                 MessageFormat.format(
456                                                         res.getString("xml_attribute_value"),
457                                                         new Object[] { attr }));
458                                 } catch (MissingResourceException e) {
459                                         tidyPrintln(e.toString());
460                                 }
461                         } else if (code == UNEXPECTED_GT) {
462                                 try {
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());
470                                 }
471                                 lexer.errors++;
472                                 ;
473                         } else if (code == UNEXPECTED_QUOTEMARK) {
474                                 try {
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());
482                                 }
483                         } else if (code == REPEATED_ATTRIBUTE) {
484                                 try {
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());
492                                 }
493                         } else if (code == PROPRIETARY_ATTR_VALUE) {
494                                 try {
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 }));
499                                         errorMessage.append(
500                                                 MessageFormat.format(
501                                                         res.getString("proprietary_attr_value"),
502                                                         new Object[] { attr }));
503                                 } catch (MissingResourceException e) {
504                                         tidyPrintln(e.toString());
505                                 }
506                         } else if (code == UNEXPECTED_END_OF_FILE) {
507                                 try {
508                                         // tidyPrint(lexer.errout, res.getString("unexpected_end_of_file"));
509                                         errorMessage.append(
510                                                 res.getString("unexpected_end_of_file"));
511                                 } catch (MissingResourceException e) {
512                                         tidyPrintln(e.toString());
513                                 }
514                         } else if (code == ID_NAME_MISMATCH) {
515                                 try {
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());
523                                 }
524                         }
525
526                         // attributes.put(IMarker.SEVERITY, new Integer(IMarker.SEVERITY_ERROR));
527                         attributes.put(
528                                 IMarker.SEVERITY,
529                                 new Integer(IMarker.SEVERITY_WARNING));
530                         // attributes.put(IMarker.SEVERITY, new Integer(IMarker.SEVERITY_INFO));
531                         attributes.put(JtidyPlugin.MARKER_NAME, Boolean.TRUE);
532                         try {
533                                 MarkerUtilities.setMessage(attributes, errorMessage.toString());
534                                 MarkerUtilities.createMarker(
535                                         lexer.getIFile(),
536                                         attributes,
537                                         IMarker.PROBLEM);
538                         } catch (CoreException e) {
539                         }
540                         tidyPrintln();
541                 } else if (code == UNEXPECTED_GT) {
542                         //   position(lexer);
543                         MarkerUtilities.setLineNumber(attributes, lexer.lines);
544                         try {
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"));
550                                 attributes.put(
551                                         IMarker.SEVERITY,
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);
556                                 try {
557                                         MarkerUtilities.setMessage(
558                                                 attributes,
559                                                 errorMessage.toString());
560                                         MarkerUtilities.createMarker(
561                                                 lexer.getIFile(),
562                                                 attributes,
563                                                 IMarker.PROBLEM);
564                                 } catch (CoreException e) {
565                                 }
566                         } catch (MissingResourceException e) {
567                                 tidyPrintln(e.toString());
568                         }
569                         tidyPrintln();
570                         lexer.errors++;
571                         ;
572                 }
573
574         }
575
576         public static void warning(
577                 Lexer lexer,
578                 Node element,
579                 Node node,
580                 short code) {
581
582               
583                 TagTable tt = lexer.configuration.tt;
584
585                 lexer.warnings++;
586
587                 /* keep quiet after 6 errors */
588                 if (lexer.errors > 6)
589                         return;
590
591                 if (lexer.configuration.ShowWarnings) {
592
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;
597                         }
598
599                         //    position(lexer);
600                         Hashtable attributes = new Hashtable();
601                         StringBuffer errorMessage =
602                                 new StringBuffer("Column " + lexer.columns + ": ");
603
604                         MarkerUtilities.setLineNumber(attributes, lexer.lines);
605
606                         if (code == MISSING_ENDTAG_FOR) {
607                                 try {
608                                         // tidyPrint(lexer.errout, MessageFormat.format(res.getString("missing_endtag_for"), new Object[] { element.element }));
609                                         errorMessage.append(
610                                                 MessageFormat.format(
611                                                         res.getString("missing_endtag_for"),
612                                                         new Object[] { element.element }));
613                                 } catch (MissingResourceException e) {
614                                         tidyPrintln(e.toString());
615                                 }
616                         } else if (code == MISSING_ENDTAG_BEFORE) {
617                                 try {
618                                         // tidyPrint(lexer.errout, MessageFormat.format(res.getString("missing_endtag_before"), new Object[] { element.element }));
619                                         errorMessage.append(
620                                                 MessageFormat.format(
621                                                         res.getString("missing_endtag_before"),
622                                                         new Object[] { element.element }));
623
624                                 } catch (MissingResourceException e) {
625                                         tidyPrintln(e.toString());
626                                 }
627                                 tag(errorMessage, node);
628                         } else if (code == DISCARDING_UNEXPECTED) {
629                                 //REVISIT: DIscarding... message
630                                 //return;
631                                 //        try {
632                                 //          // tidyPrint(lexer.errout, res.getString("discarding_unexpected"));
633                                 //          errorMessage.append(res.getString("discarding_unexpected"));
634                                 //        } catch (MissingResourceException e) {
635                                 //          tidyPrintln(e.toString());
636                                 //        }
637                                 //        tag(errorMessage, lexer, node);
638                         } else if (code == NESTED_EMPHASIS) {
639                                 try {
640                                         // tidyPrint(lexer.errout, res.getString("nested_emphasis"));
641                                         errorMessage.append(res.getString("nested_emphasis"));
642                                 } catch (MissingResourceException e) {
643                                         tidyPrintln(e.toString());
644                                 }
645                                 tag(errorMessage, node);
646                         } else if (code == COERCE_TO_ENDTAG) {
647                                 try {
648                                         // tidyPrint(lexer.errout, MessageFormat.format(res.getString("coerce_to_endtag"), new Object[] { element.element }));
649                                         errorMessage.append(
650                                                 MessageFormat.format(
651                                                         res.getString("coerce_to_endtag"),
652                                                         new Object[] { element.element }));
653                                 } catch (MissingResourceException e) {
654                                         tidyPrintln(e.toString());
655                                 }
656                         } else if (code == NON_MATCHING_ENDTAG) {
657                                 try {
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());
662                                 }
663                                 tag(errorMessage, node);
664                                 try {
665                                         // tidyPrint(lexer.errout, MessageFormat.format(res.getString("non_matching_endtag_2"), new Object[] { element.element }));
666                                         errorMessage.append(
667                                                 MessageFormat.format(
668                                                         res.getString("non_matching_endtag_2"),
669                                                         new Object[] { element.element }));
670                                 } catch (MissingResourceException e) {
671                                         tidyPrintln(e.toString());
672                                 }
673                         } else if (code == TAG_NOT_ALLOWED_IN) {
674                                 try {
675                                         // tidyPrint(lexer.errout, res.getString("warning"));
676                                         errorMessage.append(res.getString("warning"));
677                                 } catch (MissingResourceException e) {
678                                         tidyPrintln(e.toString());
679                                 }
680                                 tag(errorMessage, node);
681                                 try {
682                                         // tidyPrint(lexer.errout, MessageFormat.format(res.getString("tag_not_allowed_in"), new Object[] { element.element }));
683                                         errorMessage.append(
684                                                 MessageFormat.format(
685                                                         res.getString("tag_not_allowed_in"),
686                                                         new Object[] { element.element }));
687                                 } catch (MissingResourceException e) {
688                                         tidyPrintln(e.toString());
689                                 }
690                         } else if (code == DOCTYPE_AFTER_TAGS) {
691                                 try {
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());
696                                 }
697                         } else if (code == MISSING_STARTTAG) {
698                                 try {
699                                         // tidyPrint(lexer.errout, MessageFormat.format(res.getString("missing_starttag"), new Object[] { node.element }));
700                                         errorMessage.append(
701                                                 MessageFormat.format(
702                                                         res.getString("missing_starttag"),
703                                                         new Object[] { node.element }));
704                                 } catch (MissingResourceException e) {
705                                         tidyPrintln(e.toString());
706                                 }
707                         } else if (code == UNEXPECTED_ENDTAG) {
708                                 try {
709                                         // tidyPrint(lexer.errout, MessageFormat.format(res.getString("unexpected_endtag"), new Object[] { node.element }));
710                                         if (element != null)
711                                                 //            tidyPrint(
712                                                 //              lexer.errout,
713                                                 //              MessageFormat.format(res.getString("unexpected_endtag_suffix"), new Object[] { element.element }));
714                                                 errorMessage.append(
715                                                         MessageFormat.format(
716                                                                 res.getString("unexpected_endtag"),
717                                                                 new Object[] { node.element }));
718                                 } catch (MissingResourceException e) {
719                                         tidyPrintln(e.toString());
720                                 }
721                         } else if (code == TOO_MANY_ELEMENTS) {
722                                 try {
723                                         // tidyPrint(lexer.errout, MessageFormat.format(res.getString("too_many_elements"), new Object[] { node.element }));
724                                         if (element != null)
725                                                 //            tidyPrint(
726                                                 //              lexer.errout,
727                                                 //              MessageFormat.format(res.getString("too_many_elements_suffix"), new Object[] { element.element }));
728                                                 errorMessage.append(
729                                                         MessageFormat.format(
730                                                                 res.getString("too_many_elements"),
731                                                                 new Object[] { node.element }));
732                                 } catch (MissingResourceException e) {
733                                         tidyPrintln(e.toString());
734                                 }
735                         } else if (code == USING_BR_INPLACE_OF) {
736                                 try {
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());
741                                 }
742                                 tag(errorMessage, node);
743                         } else if (code == INSERTING_TAG) {
744                                 try {
745                                         // tidyPrint(lexer.errout, MessageFormat.format(res.getString("inserting_tag"), new Object[] { node.element }));
746                                         errorMessage.append(
747                                                 MessageFormat.format(
748                                                         res.getString("inserting_tag"),
749                                                         new Object[] { node.element }));
750                                 } catch (MissingResourceException e) {
751                                         tidyPrintln(e.toString());
752                                 }
753                         } else if (code == CANT_BE_NESTED) {
754                                 try {
755                                         // tidyPrint(lexer.errout, res.getString("warning"));
756                                         errorMessage.append(res.getString("warning"));
757                                 } catch (MissingResourceException e) {
758                                         tidyPrintln(e.toString());
759                                 }
760                                 tag(errorMessage, node);
761                                 try {
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());
766                                 }
767                         } else if (code == PROPRIETARY_ELEMENT) {
768                                 try {
769                                         // tidyPrint(lexer.errout, res.getString("warning"));
770                                         errorMessage.append(res.getString("warning"));
771                                 } catch (MissingResourceException e) {
772                                         tidyPrintln(e.toString());
773                                 }
774                                 tag(errorMessage, node);
775                                 try {
776                                         // tidyPrint(lexer.errout, res.getString("proprietary_element"));
777                                         errorMessage.append(res.getString("proprietary_element"));
778                                 } catch (MissingResourceException e) {
779                                         tidyPrintln(e.toString());
780                                 }
781
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) {
789                                 try {
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"));
794                                         } else {
795                                                 // tidyPrint(lexer.errout, res.getString("replacing_element"));
796                                                 errorMessage.append(res.getString("replacing_element"));
797                                         }
798
799                                 } catch (MissingResourceException e) {
800                                         tidyPrintln(e.toString());
801                                 }
802                                 tag(errorMessage, element);
803                                 try {
804                                         // tidyPrint(lexer.errout, res.getString("by"));
805                                         errorMessage.append(res.getString("by"));
806                                 } catch (MissingResourceException e) {
807                                         tidyPrintln(e.toString());
808                                 }
809                                 tag(errorMessage, node);
810                         } else if (code == TRIM_EMPTY_ELEMENT) {
811                                 try {
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());
816                                 }
817                                 tag(errorMessage, element);
818                         } else if (code == MISSING_TITLE_ELEMENT) {
819                                 try {
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());
824                                 }
825                         } else if (code == ILLEGAL_NESTING) {
826                                 try {
827                                         // tidyPrint(lexer.errout, res.getString("warning"));
828                                         errorMessage.append(res.getString("warning"));
829                                 } catch (MissingResourceException e) {
830                                         tidyPrintln(e.toString());
831                                 }
832                                 tag(errorMessage, element);
833                                 try {
834                                         // tidyPrint(lexer.errout, res.getString("illegal_nesting"));
835                                         errorMessage.append(res.getString("illegal_nesting"));
836                                 } catch (MissingResourceException e) {
837                                         tidyPrintln(e.toString());
838                                 }
839                         } else if (code == NOFRAMES_CONTENT) {
840                                 try {
841                                         // tidyPrint(lexer.errout, res.getString("warning"));
842                                         errorMessage.append(res.getString("warning"));
843                                 } catch (MissingResourceException e) {
844                                         tidyPrintln(e.toString());
845                                 }
846                                 tag(errorMessage, node);
847                                 try {
848                                         // tidyPrint(lexer.errout, res.getString("noframes_content"));
849                                         errorMessage.append(res.getString("noframes_content"));
850                                 } catch (MissingResourceException e) {
851                                         tidyPrintln(e.toString());
852                                 }
853                         } else if (code == INCONSISTENT_VERSION) {
854                                 try {
855                                         // tidyPrint(lexer.errout, res.getString("inconsistent_version"));
856                                         errorMessage.append(res.getString("inconsistent_version"));
857                                 } catch (MissingResourceException e) {
858                                         tidyPrintln(e.toString());
859                                 }
860                         } else if (code == MALFORMED_DOCTYPE) {
861                                 try {
862                                         // tidyPrint(lexer.errout, res.getString("malformed_doctype"));
863                                         errorMessage.append(res.getString("malformed_doctype"));
864                                 } catch (MissingResourceException e) {
865                                         tidyPrintln(e.toString());
866                                 }
867                         } else if (code == CONTENT_AFTER_BODY) {
868                                 try {
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());
873                                 }
874                         } else if (code == MALFORMED_COMMENT) {
875                                 try {
876                                         // tidyPrint(lexer.errout, res.getString("malformed_comment"));
877                                         errorMessage.append(res.getString("malformed_comment"));
878                                 } catch (MissingResourceException e) {
879                                         tidyPrintln(e.toString());
880                                 }
881                         } else if (code == BAD_COMMENT_CHARS) {
882                                 try {
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());
887                                 }
888                         } else if (code == BAD_XML_COMMENT) {
889                                 try {
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());
894                                 }
895                         } else if (code == BAD_CDATA_CONTENT) {
896                                 try {
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());
901                                 }
902                         } else if (code == INCONSISTENT_NAMESPACE) {
903                                 try {
904                                         // tidyPrint(lexer.errout, res.getString("inconsistent_namespace"));
905                                         errorMessage.append(
906                                                 res.getString("inconsistent_namespace"));
907                                 } catch (MissingResourceException e) {
908                                         tidyPrintln(e.toString());
909                                 }
910                         } else if (code == DTYPE_NOT_UPPER_CASE) {
911                                 try {
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());
916                                 }
917                         } else if (code == UNEXPECTED_END_OF_FILE) {
918                                 try {
919                                         // tidyPrint(lexer.errout, res.getString("unexpected_end_of_file"));
920                                         errorMessage.append(
921                                                 res.getString("unexpected_end_of_file"));
922                                 } catch (MissingResourceException e) {
923                                         tidyPrintln(e.toString());
924                                 }
925                                 tag(errorMessage, element);
926                         }
927                         //       attributes.put(IMarker.SEVERITY, new Integer(IMarker.SEVERITY_ERROR));
928                         attributes.put(
929                                 IMarker.SEVERITY,
930                                 new Integer(IMarker.SEVERITY_WARNING));
931                         attributes.put(JtidyPlugin.MARKER_NAME, Boolean.TRUE);
932                         //  attributes.put(IMarker.SEVERITY, new Integer(IMarker.SEVERITY_INFO));
933                         try {
934                                 MarkerUtilities.setMessage(attributes, errorMessage.toString());
935                                 MarkerUtilities.createMarker(
936                                         lexer.getIFile(),
937                                         attributes,
938                                         IMarker.PROBLEM);
939                         } catch (CoreException e) {
940                         }
941                         tidyPrintln();
942                 }
943         }
944
945         public static void error(
946                 Lexer lexer,
947                 Node element,
948                 Node node,
949                 short code) {
950                 lexer.warnings++;
951
952                 /* keep quiet after 6 errors */
953                 if (lexer.errors > 6)
954                         return;
955
956                 lexer.errors++;
957
958                 // position(lexer);
959
960                 Hashtable attributes = new Hashtable();
961                 StringBuffer errorMessage =
962                         new StringBuffer("Column " + lexer.columns + ": ");
963
964                 MarkerUtilities.setLineNumber(attributes, lexer.lines);
965
966                 if (code == SUSPECTED_MISSING_QUOTE) {
967                         try {
968                                 // tidyPrint(lexer.errout, res.getString("suspected_missing_quote"));
969                                 errorMessage.append(res.getString("suspected_missing_quote"));
970
971                         } catch (MissingResourceException e) {
972                                 tidyPrintln(e.toString());
973                         }
974                 } else if (code == DUPLICATE_FRAMESET) {
975                         try {
976                                 // tidyPrint(lexer.errout, res.getString("duplicate_frameset"));
977                                 errorMessage.append(res.getString("duplicate_frameset"));
978                         } catch (MissingResourceException e) {
979                                 tidyPrintln(e.toString());
980                         }
981                 } else if (code == UNKNOWN_ELEMENT) {
982                         try {
983                                 // tidyPrint(lexer.errout, res.getString("error"));
984                                 errorMessage.append(res.getString("error"));
985                         } catch (MissingResourceException e) {
986                                 tidyPrintln(e.toString());
987                         }
988                         tag(errorMessage, node);
989                         try {
990                                 // tidyPrint(lexer.errout, res.getString("unknown_element"));
991                                 errorMessage.append(res.getString("unknown_element"));
992                         } catch (MissingResourceException e) {
993                                 tidyPrintln(e.toString());
994                         }
995                 } else if (code == UNEXPECTED_ENDTAG) {
996                         try {
997                                 // tidyPrint(lexer.errout, MessageFormat.format(res.getString("unexpected_endtag"), new Object[] { node.element }));
998                                 errorMessage.append(
999                                         MessageFormat.format(
1000                                                 res.getString("unexpected_endtag"),
1001                                                 new Object[] { node.element }));
1002                                 if (element != null) {
1003                                         //          tidyPrint(
1004                                         //            lexer.errout,
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 }));
1007                                 }
1008                         } catch (MissingResourceException e) {
1009                                 tidyPrintln(e.toString());
1010                         }
1011                 }
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);
1016                 try {
1017                         MarkerUtilities.setMessage(attributes, errorMessage.toString());
1018                         MarkerUtilities.createMarker(
1019                                 lexer.getIFile(),
1020                                 attributes,
1021                                 IMarker.PROBLEM);
1022                 } catch (CoreException e) {
1023                 }
1024                 //   tidyPrintln(lexer.errout);
1025         }
1026
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);
1033                 }
1034
1035                 Hashtable attributes = new Hashtable();
1036                 StringBuffer errorMessage =
1037                         new StringBuffer("Column " + lexer.columns + ": ");
1038
1039                 MarkerUtilities.setLineNumber(attributes, lexer.lines);
1040
1041                 if (lexer.badChars != 0) {
1042                         if ((lexer.badChars & WINDOWS_CHARS) != 0) {
1043                                 try {
1044                                         // tidyPrint(lexer.errout, res.getString("badchars_summary"));
1045                                         errorMessage.append(res.getString("badchars_summary"));
1046                                 } catch (MissingResourceException e) {
1047                                         tidyPrintln(e.toString());
1048                                 }
1049                         }
1050                 }
1051
1052                 if (lexer.badForm != 0) {
1053                         try {
1054                                 // tidyPrint(lexer.errout, res.getString("badform_summary"));
1055                                 errorMessage.append(res.getString("badform_summary"));
1056                         } catch (MissingResourceException e) {
1057                                 tidyPrintln(e.toString());
1058                         }
1059                 }
1060
1061                 if (lexer.badAccess != 0) {
1062                         if ((lexer.badAccess & MISSING_SUMMARY) != 0) {
1063                                 try {
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());
1069                                 }
1070                         }
1071
1072                         if ((lexer.badAccess & MISSING_IMAGE_ALT) != 0) {
1073                                 try {
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());
1079                                 }
1080                         }
1081
1082                         if ((lexer.badAccess & MISSING_IMAGE_MAP) != 0) {
1083                                 try {
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());
1089                                 }
1090                         }
1091
1092                         if ((lexer.badAccess & MISSING_LINK_ALT) != 0) {
1093                                 try {
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());
1099                                 }
1100                         }
1101
1102                         if (((lexer.badAccess & USING_FRAMES) != 0)
1103                                 && ((lexer.badAccess & USING_NOFRAMES) == 0)) {
1104                                 try {
1105                                         // tidyPrint(lexer.errout, res.getString("badaccess_frames"));
1106                                         errorMessage.append(res.getString("badaccess_frames"));
1107                                 } catch (MissingResourceException e) {
1108                                         tidyPrintln(e.toString());
1109                                 }
1110                         }
1111
1112                         try {
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());
1120                         }
1121                 }
1122
1123                 if (lexer.badLayout != 0) {
1124                         if ((lexer.badLayout & USING_LAYER) != 0) {
1125                                 try {
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());
1130                                 }
1131                         }
1132
1133                         if ((lexer.badLayout & USING_SPACER) != 0) {
1134                                 try {
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());
1140                                 }
1141                         }
1142
1143                         if ((lexer.badLayout & USING_FONT) != 0) {
1144                                 try {
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());
1149                                 }
1150                         }
1151
1152                         if ((lexer.badLayout & USING_NOBR) != 0) {
1153                                 try {
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());
1158                                 }
1159                         }
1160
1161                         if ((lexer.badLayout & USING_BODY) != 0) {
1162                                 try {
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());
1167                                 }
1168                         }
1169                         attributes.put(
1170                                 IMarker.SEVERITY,
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);
1175                         try {
1176                                 MarkerUtilities.setMessage(attributes, errorMessage.toString());
1177                                 MarkerUtilities.createMarker(
1178                                         lexer.getIFile(),
1179                                         attributes,
1180                                         IMarker.PROBLEM);
1181                         } catch (CoreException e) {
1182                         }
1183                 }
1184         }
1185
1186         public static void unknownOption(PrintWriter errout, char c) {
1187                 try {
1188                         tidyPrintln(
1189                                 MessageFormat.format(
1190                                         res.getString("unrecognized_option"),
1191                                         new Object[] { new String(new char[] { c })
1192                         }));
1193                 } catch (MissingResourceException e) {
1194                         tidyPrintln(e.toString());
1195                 }
1196         }
1197
1198         public static void unknownFile(
1199                 PrintWriter errout,
1200                 String program,
1201                 String file) {
1202                 try {
1203                         tidyPrintln(
1204                                 MessageFormat.format(
1205                                         res.getString("unknown_file"),
1206                                         new Object[] { program, file }));
1207                 } catch (MissingResourceException e) {
1208                         tidyPrintln(e.toString());
1209                 }
1210         }
1211
1212         public static void needsAuthorIntervention(PrintWriter errout) {
1213                 try {
1214                         tidyPrintln(res.getString("needs_author_intervention"));
1215                 } catch (MissingResourceException e) {
1216                         tidyPrintln(e.toString());
1217                 }
1218         }
1219
1220         public static void missingBody(PrintWriter errout) {
1221                 try {
1222                         tidyPrintln(res.getString("missing_body"));
1223                 } catch (MissingResourceException e) {
1224                         tidyPrintln(e.toString());
1225                 }
1226         }
1227
1228         public static void reportNumberOfSlides(PrintWriter errout, int count) {
1229                 try {
1230                         tidyPrintln(
1231                                 MessageFormat.format(
1232                                         res.getString("slides_found"),
1233                                         new Object[] { new Integer(count)}));
1234                 } catch (MissingResourceException e) {
1235                         tidyPrintln(e.toString());
1236                 }
1237         }
1238
1239         public static void generalInfo(PrintWriter errout) {
1240                 try {
1241                         tidyPrintln(res.getString("general_info"));
1242                 } catch (MissingResourceException e) {
1243                         tidyPrintln(e.toString());
1244                 }
1245         }
1246
1247         public static void helloMessage(
1248                 PrintWriter errout,
1249                 String date,
1250                 String filename) {
1251                 currentFile = filename; /* for use with Gnu Emacs */
1252
1253                 try {
1254                         tidyPrintln(
1255                                 MessageFormat.format(
1256                                         res.getString("hello_message"),
1257                                         new Object[] { date, filename }));
1258                 } catch (MissingResourceException e) {
1259                         tidyPrintln(e.toString());
1260                 }
1261         }
1262
1263         public static void reportVersion(
1264                 PrintWriter errout,
1265                 Lexer lexer,
1266                 String filename,
1267                 Node doctype) {
1268                 int i, c;
1269                 int state = 0;
1270                 String vers = lexer.HTMLVersionName();
1271                 MutableInteger cc = new MutableInteger();
1272
1273                 try {
1274                         if (doctype != null) {
1275                                 tidyPrint(
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];
1282
1283                                         /* look for UTF-8 multibyte character */
1284                                         if (c < 0) {
1285                                                 i += PPrint.getUTF8(doctype.textarray, i, cc);
1286                                                 c = cc.value;
1287                                         }
1288
1289                                         if (c == (char) '"')
1290                                                 ++state;
1291                                         else if (state == 1) {
1292                                                 buf.append(c);
1293                                         // tidyPrint((char) c);
1294                                         }
1295                                 }
1296
1297                         //      tidyPrint('"');
1298                                 buf.append('"');
1299                                 tidyPrint( buf.toString() );
1300                         }
1301
1302                         tidyPrintln(
1303                                 MessageFormat.format(
1304                                         res.getString("report_version"),
1305                                         new Object[] {
1306                                                 filename,
1307                                                 (vers != null ? vers : "HTML proprietary")}));
1308                 } catch (MissingResourceException e) {
1309                         tidyPrintln(e.toString());
1310                 }
1311         }
1312
1313         public static void reportNumWarnings(PrintWriter errout, Lexer lexer) {
1314                 if (lexer.warnings > 0) {
1315                         try {
1316                                 tidyPrintln(
1317                                         MessageFormat.format(
1318                                                 res.getString("num_warnings"),
1319                                                 new Object[] { new Integer(lexer.warnings)}));
1320                         } catch (MissingResourceException e) {
1321                                 tidyPrintln(e.toString());
1322                         }
1323                 } else {
1324                         try {
1325                                 tidyPrintln(res.getString("no_warnings"));
1326                         } catch (MissingResourceException e) {
1327                                 tidyPrintln(e.toString());
1328                         }
1329                 }
1330         }
1331
1332         public static void helpText(PrintWriter out, String prog) {
1333                 try {
1334                         tidyPrintln(
1335                                 MessageFormat.format(
1336                                         res.getString("help_text"),
1337                                         new Object[] { prog, RELEASE_DATE }));
1338                 } catch (MissingResourceException e) {
1339                         tidyPrintln(e.toString());
1340                 }
1341         }
1342
1343         public static void badTree(PrintWriter errout) {
1344                 try {
1345                         tidyPrintln(res.getString("bad_tree"));
1346                 } catch (MissingResourceException e) {
1347                         tidyPrintln(e.toString());
1348                 }
1349         }
1350
1351 }