1 |
| |
2 |
| |
3 |
| |
4 |
| |
5 |
| |
6 |
| |
7 |
| |
8 |
| |
9 |
| |
10 |
| |
11 |
| |
12 |
| |
13 |
| |
14 |
| |
15 |
| |
16 |
| |
17 |
| |
18 |
| |
19 |
| |
20 |
| |
21 |
| |
22 |
| |
23 |
| |
24 |
| |
25 |
| |
26 |
| |
27 |
| |
28 |
| |
29 |
| |
30 |
| |
31 |
| |
32 |
| |
33 |
| |
34 |
| |
35 |
| |
36 |
| |
37 |
| |
38 |
| |
39 |
| |
40 |
| |
41 |
| |
42 |
| |
43 |
| |
44 |
| |
45 |
| |
46 |
| |
47 |
| |
48 |
| |
49 |
| |
50 |
| |
51 |
| |
52 |
| |
53 |
| |
54 |
| package org.w3c.tidy; |
55 |
| |
56 |
| import java.io.PrintWriter; |
57 |
| import java.text.MessageFormat; |
58 |
| import java.text.SimpleDateFormat; |
59 |
| import java.util.Date; |
60 |
| import java.util.MissingResourceException; |
61 |
| import java.util.ResourceBundle; |
62 |
| |
63 |
| import org.w3c.tidy.TidyMessage.Level; |
64 |
| |
65 |
| |
66 |
| |
67 |
| |
68 |
| |
69 |
| |
70 |
| |
71 |
| |
72 |
| |
73 |
| |
74 |
| public final class Report |
75 |
| { |
76 |
| |
77 |
| |
78 |
| |
79 |
| |
80 |
| public static final String ACCESS_URL = "http://www.w3.org/WAI/GL"; |
81 |
| |
82 |
| |
83 |
| |
84 |
| |
85 |
| public static final Date RELEASE_DATE = new Date(1096227718000L); |
86 |
| |
87 |
| |
88 |
| |
89 |
| |
90 |
| public static final String RELEASE_DATE_STRING = new SimpleDateFormat("dd MMM yyyy").format(RELEASE_DATE); |
91 |
| |
92 |
| |
93 |
| |
94 |
| |
95 |
| public static final short MISSING_SEMICOLON = 1; |
96 |
| |
97 |
| |
98 |
| |
99 |
| |
100 |
| public static final short MISSING_SEMICOLON_NCR = 2; |
101 |
| |
102 |
| |
103 |
| |
104 |
| |
105 |
| public static final short UNKNOWN_ENTITY = 3; |
106 |
| |
107 |
| |
108 |
| |
109 |
| |
110 |
| public static final short UNESCAPED_AMPERSAND = 4; |
111 |
| |
112 |
| |
113 |
| |
114 |
| |
115 |
| public static final short APOS_UNDEFINED = 5; |
116 |
| |
117 |
| |
118 |
| |
119 |
| |
120 |
| public static final short MISSING_ENDTAG_FOR = 6; |
121 |
| |
122 |
| |
123 |
| |
124 |
| |
125 |
| public static final short MISSING_ENDTAG_BEFORE = 7; |
126 |
| |
127 |
| |
128 |
| |
129 |
| |
130 |
| public static final short DISCARDING_UNEXPECTED = 8; |
131 |
| |
132 |
| |
133 |
| |
134 |
| |
135 |
| public static final short NESTED_EMPHASIS = 9; |
136 |
| |
137 |
| |
138 |
| |
139 |
| |
140 |
| public static final short NON_MATCHING_ENDTAG = 10; |
141 |
| |
142 |
| |
143 |
| |
144 |
| |
145 |
| public static final short TAG_NOT_ALLOWED_IN = 11; |
146 |
| |
147 |
| |
148 |
| |
149 |
| |
150 |
| public static final short MISSING_STARTTAG = 12; |
151 |
| |
152 |
| |
153 |
| |
154 |
| |
155 |
| public static final short UNEXPECTED_ENDTAG = 13; |
156 |
| |
157 |
| |
158 |
| |
159 |
| |
160 |
| public static final short USING_BR_INPLACE_OF = 14; |
161 |
| |
162 |
| |
163 |
| |
164 |
| |
165 |
| public static final short INSERTING_TAG = 15; |
166 |
| |
167 |
| |
168 |
| |
169 |
| |
170 |
| public static final short SUSPECTED_MISSING_QUOTE = 16; |
171 |
| |
172 |
| |
173 |
| |
174 |
| |
175 |
| public static final short MISSING_TITLE_ELEMENT = 17; |
176 |
| |
177 |
| |
178 |
| |
179 |
| |
180 |
| public static final short DUPLICATE_FRAMESET = 18; |
181 |
| |
182 |
| |
183 |
| |
184 |
| |
185 |
| public static final short CANT_BE_NESTED = 19; |
186 |
| |
187 |
| |
188 |
| |
189 |
| |
190 |
| public static final short OBSOLETE_ELEMENT = 20; |
191 |
| |
192 |
| |
193 |
| |
194 |
| |
195 |
| public static final short PROPRIETARY_ELEMENT = 21; |
196 |
| |
197 |
| |
198 |
| |
199 |
| |
200 |
| public static final short UNKNOWN_ELEMENT = 22; |
201 |
| |
202 |
| |
203 |
| |
204 |
| |
205 |
| public static final short TRIM_EMPTY_ELEMENT = 23; |
206 |
| |
207 |
| |
208 |
| |
209 |
| |
210 |
| public static final short COERCE_TO_ENDTAG = 24; |
211 |
| |
212 |
| |
213 |
| |
214 |
| |
215 |
| public static final short ILLEGAL_NESTING = 25; |
216 |
| |
217 |
| |
218 |
| |
219 |
| |
220 |
| public static final short NOFRAMES_CONTENT = 26; |
221 |
| |
222 |
| |
223 |
| |
224 |
| |
225 |
| public static final short CONTENT_AFTER_BODY = 27; |
226 |
| |
227 |
| |
228 |
| |
229 |
| |
230 |
| public static final short INCONSISTENT_VERSION = 28; |
231 |
| |
232 |
| |
233 |
| |
234 |
| |
235 |
| public static final short MALFORMED_COMMENT = 29; |
236 |
| |
237 |
| |
238 |
| |
239 |
| |
240 |
| public static final short BAD_COMMENT_CHARS = 30; |
241 |
| |
242 |
| |
243 |
| |
244 |
| |
245 |
| public static final short BAD_XML_COMMENT = 31; |
246 |
| |
247 |
| |
248 |
| |
249 |
| |
250 |
| public static final short BAD_CDATA_CONTENT = 32; |
251 |
| |
252 |
| |
253 |
| |
254 |
| |
255 |
| public static final short INCONSISTENT_NAMESPACE = 33; |
256 |
| |
257 |
| |
258 |
| |
259 |
| |
260 |
| public static final short DOCTYPE_AFTER_TAGS = 34; |
261 |
| |
262 |
| |
263 |
| |
264 |
| |
265 |
| public static final short MALFORMED_DOCTYPE = 35; |
266 |
| |
267 |
| |
268 |
| |
269 |
| |
270 |
| public static final short UNEXPECTED_END_OF_FILE = 36; |
271 |
| |
272 |
| |
273 |
| |
274 |
| |
275 |
| public static final short DTYPE_NOT_UPPER_CASE = 37; |
276 |
| |
277 |
| |
278 |
| |
279 |
| |
280 |
| public static final short TOO_MANY_ELEMENTS = 38; |
281 |
| |
282 |
| |
283 |
| |
284 |
| |
285 |
| public static final short UNESCAPED_ELEMENT = 39; |
286 |
| |
287 |
| |
288 |
| |
289 |
| |
290 |
| public static final short NESTED_QUOTATION = 40; |
291 |
| |
292 |
| |
293 |
| |
294 |
| |
295 |
| public static final short ELEMENT_NOT_EMPTY = 41; |
296 |
| |
297 |
| |
298 |
| |
299 |
| |
300 |
| public static final short ENCODING_IO_CONFLICT = 42; |
301 |
| |
302 |
| |
303 |
| |
304 |
| |
305 |
| public static final short MIXED_CONTENT_IN_BLOCK = 43; |
306 |
| |
307 |
| |
308 |
| |
309 |
| |
310 |
| public static final short MISSING_DOCTYPE = 44; |
311 |
| |
312 |
| |
313 |
| |
314 |
| |
315 |
| public static final short SPACE_PRECEDING_XMLDECL = 45; |
316 |
| |
317 |
| |
318 |
| |
319 |
| |
320 |
| public static final short TOO_MANY_ELEMENTS_IN = 46; |
321 |
| |
322 |
| |
323 |
| |
324 |
| |
325 |
| public static final short UNEXPECTED_ENDTAG_IN = 47; |
326 |
| |
327 |
| |
328 |
| |
329 |
| |
330 |
| public static final short REPLACING_ELEMENT = 83; |
331 |
| |
332 |
| |
333 |
| |
334 |
| |
335 |
| public static final short REPLACING_UNEX_ELEMENT = 84; |
336 |
| |
337 |
| |
338 |
| |
339 |
| |
340 |
| public static final short COERCE_TO_ENDTAG_WARN = 85; |
341 |
| |
342 |
| |
343 |
| |
344 |
| |
345 |
| public static final short UNKNOWN_ATTRIBUTE = 48; |
346 |
| |
347 |
| |
348 |
| |
349 |
| |
350 |
| public static final short MISSING_ATTRIBUTE = 49; |
351 |
| |
352 |
| |
353 |
| |
354 |
| |
355 |
| public static final short MISSING_ATTR_VALUE = 50; |
356 |
| |
357 |
| |
358 |
| |
359 |
| |
360 |
| public static final short BAD_ATTRIBUTE_VALUE = 51; |
361 |
| |
362 |
| |
363 |
| |
364 |
| |
365 |
| public static final short UNEXPECTED_GT = 52; |
366 |
| |
367 |
| |
368 |
| |
369 |
| |
370 |
| public static final short PROPRIETARY_ATTRIBUTE = 53; |
371 |
| |
372 |
| |
373 |
| |
374 |
| |
375 |
| public static final short PROPRIETARY_ATTR_VALUE = 54; |
376 |
| |
377 |
| |
378 |
| |
379 |
| |
380 |
| public static final short REPEATED_ATTRIBUTE = 55; |
381 |
| |
382 |
| |
383 |
| |
384 |
| |
385 |
| public static final short MISSING_IMAGEMAP = 56; |
386 |
| |
387 |
| |
388 |
| |
389 |
| |
390 |
| public static final short XML_ATTRIBUTE_VALUE = 57; |
391 |
| |
392 |
| |
393 |
| |
394 |
| |
395 |
| public static final short MISSING_QUOTEMARK = 58; |
396 |
| |
397 |
| |
398 |
| |
399 |
| |
400 |
| public static final short UNEXPECTED_QUOTEMARK = 59; |
401 |
| |
402 |
| |
403 |
| |
404 |
| |
405 |
| public static final short ID_NAME_MISMATCH = 60; |
406 |
| |
407 |
| |
408 |
| |
409 |
| |
410 |
| public static final short BACKSLASH_IN_URI = 61; |
411 |
| |
412 |
| |
413 |
| |
414 |
| |
415 |
| public static final short FIXED_BACKSLASH = 62; |
416 |
| |
417 |
| |
418 |
| |
419 |
| |
420 |
| public static final short ILLEGAL_URI_REFERENCE = 63; |
421 |
| |
422 |
| |
423 |
| |
424 |
| |
425 |
| public static final short ESCAPED_ILLEGAL_URI = 64; |
426 |
| |
427 |
| |
428 |
| |
429 |
| |
430 |
| public static final short NEWLINE_IN_URI = 65; |
431 |
| |
432 |
| |
433 |
| |
434 |
| |
435 |
| public static final short ANCHOR_NOT_UNIQUE = 66; |
436 |
| |
437 |
| |
438 |
| |
439 |
| |
440 |
| public static final short ENTITY_IN_ID = 67; |
441 |
| |
442 |
| |
443 |
| |
444 |
| |
445 |
| public static final short JOINING_ATTRIBUTE = 68; |
446 |
| |
447 |
| |
448 |
| |
449 |
| |
450 |
| public static final short UNEXPECTED_EQUALSIGN = 69; |
451 |
| |
452 |
| |
453 |
| |
454 |
| |
455 |
| public static final short ATTR_VALUE_NOT_LCASE = 70; |
456 |
| |
457 |
| |
458 |
| |
459 |
| |
460 |
| public static final short XML_ID_SYNTAX = 71; |
461 |
| |
462 |
| |
463 |
| |
464 |
| |
465 |
| public static final short INVALID_ATTRIBUTE = 72; |
466 |
| |
467 |
| |
468 |
| |
469 |
| |
470 |
| public static final short BAD_ATTRIBUTE_VALUE_REPLACED = 73; |
471 |
| |
472 |
| |
473 |
| |
474 |
| |
475 |
| public static final short INVALID_XML_ID = 74; |
476 |
| |
477 |
| |
478 |
| |
479 |
| |
480 |
| public static final short UNEXPECTED_END_OF_FILE_ATTR = 75; |
481 |
| |
482 |
| |
483 |
| |
484 |
| |
485 |
| public static final short VENDOR_SPECIFIC_CHARS = 76; |
486 |
| |
487 |
| |
488 |
| |
489 |
| |
490 |
| public static final short INVALID_SGML_CHARS = 77; |
491 |
| |
492 |
| |
493 |
| |
494 |
| |
495 |
| public static final short INVALID_UTF8 = 78; |
496 |
| |
497 |
| |
498 |
| |
499 |
| |
500 |
| public static final short INVALID_UTF16 = 79; |
501 |
| |
502 |
| |
503 |
| |
504 |
| |
505 |
| public static final short ENCODING_MISMATCH = 80; |
506 |
| |
507 |
| |
508 |
| |
509 |
| |
510 |
| public static final short INVALID_URI = 81; |
511 |
| |
512 |
| |
513 |
| |
514 |
| |
515 |
| public static final short INVALID_NCR = 82; |
516 |
| |
517 |
| |
518 |
| |
519 |
| |
520 |
| public static final short DOCTYPE_GIVEN_SUMMARY = 110; |
521 |
| |
522 |
| |
523 |
| |
524 |
| |
525 |
| public static final short REPORT_VERSION_SUMMARY = 111; |
526 |
| |
527 |
| |
528 |
| |
529 |
| |
530 |
| public static final short BADACCESS_SUMMARY = 112; |
531 |
| |
532 |
| |
533 |
| |
534 |
| |
535 |
| public static final short BADFORM_SUMMARY = 113; |
536 |
| |
537 |
| |
538 |
| |
539 |
| |
540 |
| public static final short MISSING_IMAGE_ALT = 1; |
541 |
| |
542 |
| |
543 |
| |
544 |
| |
545 |
| public static final short MISSING_LINK_ALT = 2; |
546 |
| |
547 |
| |
548 |
| |
549 |
| |
550 |
| public static final short MISSING_SUMMARY = 4; |
551 |
| |
552 |
| |
553 |
| |
554 |
| |
555 |
| public static final short MISSING_IMAGE_MAP = 8; |
556 |
| |
557 |
| |
558 |
| |
559 |
| |
560 |
| public static final short USING_FRAMES = 16; |
561 |
| |
562 |
| |
563 |
| |
564 |
| |
565 |
| public static final short USING_NOFRAMES = 32; |
566 |
| |
567 |
| |
568 |
| |
569 |
| |
570 |
| public static final short USING_SPACER = 1; |
571 |
| |
572 |
| |
573 |
| |
574 |
| |
575 |
| public static final short USING_LAYER = 2; |
576 |
| |
577 |
| |
578 |
| |
579 |
| |
580 |
| public static final short USING_NOBR = 4; |
581 |
| |
582 |
| |
583 |
| |
584 |
| |
585 |
| public static final short USING_FONT = 8; |
586 |
| |
587 |
| |
588 |
| |
589 |
| |
590 |
| public static final short USING_BODY = 16; |
591 |
| |
592 |
| |
593 |
| |
594 |
| |
595 |
| public static final short WINDOWS_CHARS = 1; |
596 |
| |
597 |
| |
598 |
| |
599 |
| |
600 |
| public static final short NON_ASCII = 2; |
601 |
| |
602 |
| |
603 |
| |
604 |
| |
605 |
| public static final short FOUND_UTF16 = 4; |
606 |
| |
607 |
| |
608 |
| |
609 |
| |
610 |
| public static final short REPLACED_CHAR = 0; |
611 |
| |
612 |
| |
613 |
| |
614 |
| |
615 |
| public static final short DISCARDED_CHAR = 1; |
616 |
| |
617 |
| |
618 |
| |
619 |
| |
620 |
| private static ResourceBundle res; |
621 |
| |
622 |
| |
623 |
| |
624 |
| |
625 |
| private String currentFile; |
626 |
| |
627 |
| |
628 |
| |
629 |
| |
630 |
| private TidyMessageListener listener; |
631 |
| |
632 |
| static |
633 |
| { |
634 |
1
| try
|
635 |
| { |
636 |
1
| res = ResourceBundle.getBundle("org/w3c/tidy/TidyMessages");
|
637 |
| } |
638 |
| catch (MissingResourceException e) |
639 |
| { |
640 |
0
| throw new Error(e.toString());
|
641 |
| } |
642 |
| } |
643 |
| |
644 |
| |
645 |
| |
646 |
| |
647 |
299
| protected Report()
|
648 |
| { |
649 |
299
| super();
|
650 |
| } |
651 |
| |
652 |
| |
653 |
| |
654 |
| |
655 |
| |
656 |
| |
657 |
| |
658 |
| |
659 |
| |
660 |
| |
661 |
| |
662 |
| |
663 |
| |
664 |
| |
665 |
| |
666 |
| |
667 |
| |
668 |
| |
669 |
| |
670 |
2524
| protected String getMessage(int errorCode, Lexer lexer, String message, Object[] params, Level level)
|
671 |
| throws MissingResourceException |
672 |
| { |
673 |
2524
| String resource;
|
674 |
2524
| resource = res.getString(message);
|
675 |
| |
676 |
2524
| String position;
|
677 |
| |
678 |
2524
| if (lexer != null && level != Level.SUMMARY)
|
679 |
| { |
680 |
1613
| position = getPosition(lexer);
|
681 |
| } |
682 |
| else |
683 |
| { |
684 |
911
| position = "";
|
685 |
| } |
686 |
| |
687 |
2524
| String prefix;
|
688 |
| |
689 |
2524
| if (level == Level.ERROR)
|
690 |
| { |
691 |
39
| prefix = res.getString("error");
|
692 |
| } |
693 |
2485
| else if (level == Level.WARNING)
|
694 |
| { |
695 |
1547
| prefix = res.getString("warning");
|
696 |
| } |
697 |
| else |
698 |
| { |
699 |
938
| prefix = "";
|
700 |
| } |
701 |
| |
702 |
2524
| String messageString;
|
703 |
| |
704 |
2524
| if (params != null)
|
705 |
| { |
706 |
2187
| messageString = MessageFormat.format(resource, params);
|
707 |
| } |
708 |
| else |
709 |
| { |
710 |
337
| messageString = resource;
|
711 |
| } |
712 |
| |
713 |
2524
| if (listener != null)
|
714 |
| { |
715 |
2375
| TidyMessage msg = new TidyMessage(errorCode, (lexer != null) ? lexer.lines : 0, (lexer != null)
|
716 |
| ? lexer.columns |
717 |
| : 0, level, messageString); |
718 |
2375
| listener.messageReceived(msg);
|
719 |
| } |
720 |
| |
721 |
2524
| return position + prefix + messageString;
|
722 |
| } |
723 |
| |
724 |
| |
725 |
| |
726 |
| |
727 |
| |
728 |
| |
729 |
| |
730 |
| |
731 |
| |
732 |
| |
733 |
| |
734 |
1991
| private void printMessage(int errorCode, Lexer lexer, String message, Object[] params, Level level)
|
735 |
| { |
736 |
1991
| String resource;
|
737 |
1991
| try
|
738 |
| { |
739 |
1991
| resource = getMessage(errorCode, lexer, message, params, level);
|
740 |
| } |
741 |
| catch (MissingResourceException e) |
742 |
| { |
743 |
0
| lexer.errout.println(e.toString());
|
744 |
0
| return;
|
745 |
| } |
746 |
| |
747 |
1991
| lexer.errout.println(resource);
|
748 |
| } |
749 |
| |
750 |
| |
751 |
| |
752 |
| |
753 |
| |
754 |
| |
755 |
| |
756 |
| |
757 |
| |
758 |
| |
759 |
481
| private void printMessage(PrintWriter errout, String message, Object[] params, Level level)
|
760 |
| { |
761 |
481
| String resource;
|
762 |
481
| try
|
763 |
| { |
764 |
481
| resource = getMessage(-1, null, message, params, level);
|
765 |
| } |
766 |
| catch (MissingResourceException e) |
767 |
| { |
768 |
0
| errout.println(e.toString());
|
769 |
0
| return;
|
770 |
| } |
771 |
481
| errout.println(resource);
|
772 |
| } |
773 |
| |
774 |
| |
775 |
| |
776 |
| |
777 |
| |
778 |
0
| public void showVersion(PrintWriter p)
|
779 |
| { |
780 |
0
| printMessage(p, "version_summary", new Object[]{RELEASE_DATE}, Level.SUMMARY);
|
781 |
| } |
782 |
| |
783 |
| |
784 |
| |
785 |
| |
786 |
| |
787 |
| |
788 |
713
| private String getTagName(Node tag)
|
789 |
| { |
790 |
713
| if (tag != null)
|
791 |
| { |
792 |
713
| if (tag.type == Node.START_TAG)
|
793 |
| { |
794 |
603
| return "<" + tag.element + ">";
|
795 |
| } |
796 |
110
| else if (tag.type == Node.END_TAG)
|
797 |
| { |
798 |
93
| return "</" + tag.element + ">";
|
799 |
| } |
800 |
17
| else if (tag.type == Node.DOCTYPE_TAG)
|
801 |
| { |
802 |
0
| return "<!DOCTYPE>";
|
803 |
| } |
804 |
17
| else if (tag.type == Node.TEXT_NODE)
|
805 |
| { |
806 |
4
| return "plain text";
|
807 |
| } |
808 |
| else |
809 |
| { |
810 |
13
| return tag.element;
|
811 |
| } |
812 |
| } |
813 |
0
| return "";
|
814 |
| } |
815 |
| |
816 |
| |
817 |
| |
818 |
| |
819 |
| |
820 |
0
| public void unknownOption(String option)
|
821 |
| { |
822 |
0
| try
|
823 |
| { |
824 |
0
| System.err.println(MessageFormat.format(res.getString("unknown_option"), new Object[]{option}));
|
825 |
| } |
826 |
| catch (MissingResourceException e) |
827 |
| { |
828 |
0
| System.err.println(e.toString());
|
829 |
| } |
830 |
| } |
831 |
| |
832 |
| |
833 |
| |
834 |
| |
835 |
| |
836 |
| |
837 |
0
| public void badArgument(String key, String value)
|
838 |
| { |
839 |
0
| try
|
840 |
| { |
841 |
0
| System.err.println(MessageFormat.format(res.getString("bad_argument"), new Object[]{value, key}));
|
842 |
| } |
843 |
| catch (MissingResourceException e) |
844 |
| { |
845 |
0
| System.err.println(e.toString());
|
846 |
| } |
847 |
| } |
848 |
| |
849 |
| |
850 |
| |
851 |
| |
852 |
| |
853 |
| |
854 |
1613
| private String getPosition(Lexer lexer)
|
855 |
| { |
856 |
1613
| try
|
857 |
| { |
858 |
| |
859 |
1613
| if (lexer.configuration.emacs)
|
860 |
| { |
861 |
0
| return MessageFormat.format(res.getString("emacs_format"), new Object[]{
|
862 |
| this.currentFile, |
863 |
| new Integer(lexer.lines), |
864 |
| new Integer(lexer.columns)}) |
865 |
| + " "; |
866 |
| } |
867 |
| |
868 |
1613
| return MessageFormat.format(res.getString("line_column"), new Object[]{
|
869 |
| new Integer(lexer.lines), |
870 |
| new Integer(lexer.columns)}); |
871 |
| |
872 |
| } |
873 |
| catch (MissingResourceException e) |
874 |
| { |
875 |
0
| lexer.errout.println(e.toString());
|
876 |
| } |
877 |
0
| return "";
|
878 |
| } |
879 |
| |
880 |
| |
881 |
| |
882 |
| |
883 |
| |
884 |
| |
885 |
| |
886 |
0
| public void encodingError(Lexer lexer, int code, int c)
|
887 |
| { |
888 |
0
| lexer.warnings++;
|
889 |
| |
890 |
0
| if (lexer.errors > lexer.configuration.showErrors)
|
891 |
| { |
892 |
0
| return;
|
893 |
| } |
894 |
| |
895 |
0
| if (lexer.configuration.showWarnings)
|
896 |
| { |
897 |
0
| String buf = Integer.toHexString(c);
|
898 |
| |
899 |
| |
900 |
0
| if ((code & ~DISCARDED_CHAR) == ENCODING_MISMATCH)
|
901 |
| { |
902 |
| |
903 |
0
| lexer.badChars |= ENCODING_MISMATCH;
|
904 |
0
| printMessage(
|
905 |
| code, |
906 |
| lexer, |
907 |
| "encoding_mismatch", |
908 |
| new Object[]{ |
909 |
| lexer.configuration.getInCharEncodingName(), |
910 |
| ParsePropertyImpl.CHAR_ENCODING.getFriendlyName(null, new Integer(c), lexer.configuration)}, |
911 |
| Level.WARNING); |
912 |
| } |
913 |
0
| else if ((code & ~DISCARDED_CHAR) == VENDOR_SPECIFIC_CHARS)
|
914 |
| { |
915 |
0
| lexer.badChars |= VENDOR_SPECIFIC_CHARS;
|
916 |
0
| printMessage(
|
917 |
| code, |
918 |
| lexer, |
919 |
| "invalid_char", |
920 |
| new Object[]{new Integer(code & DISCARDED_CHAR), buf}, |
921 |
| Level.WARNING); |
922 |
| } |
923 |
0
| else if ((code & ~DISCARDED_CHAR) == INVALID_SGML_CHARS)
|
924 |
| { |
925 |
0
| lexer.badChars |= INVALID_SGML_CHARS;
|
926 |
0
| printMessage(
|
927 |
| code, |
928 |
| lexer, |
929 |
| "invalid_char", |
930 |
| new Object[]{new Integer(code & DISCARDED_CHAR), buf}, |
931 |
| Level.WARNING); |
932 |
| } |
933 |
0
| else if ((code & ~DISCARDED_CHAR) == INVALID_UTF8)
|
934 |
| { |
935 |
0
| lexer.badChars |= INVALID_UTF8;
|
936 |
0
| printMessage(
|
937 |
| code, |
938 |
| lexer, |
939 |
| "invalid_utf8", |
940 |
| new Object[]{new Integer(code & DISCARDED_CHAR), buf}, |
941 |
| Level.WARNING); |
942 |
| } |
943 |
| |
944 |
0
| else if ((code & ~DISCARDED_CHAR) == INVALID_UTF16)
|
945 |
| { |
946 |
0
| lexer.badChars |= INVALID_UTF16;
|
947 |
0
| printMessage(
|
948 |
| code, |
949 |
| lexer, |
950 |
| "invalid_utf16", |
951 |
| new Object[]{new Integer(code & DISCARDED_CHAR), buf}, |
952 |
| Level.WARNING); |
953 |
| |
954 |
| } |
955 |
| |
956 |
0
| else if ((code & ~DISCARDED_CHAR) == INVALID_NCR)
|
957 |
| { |
958 |
0
| lexer.badChars |= INVALID_NCR;
|
959 |
0
| printMessage(
|
960 |
| code, |
961 |
| lexer, |
962 |
| "invalid_ncr", |
963 |
| new Object[]{new Integer(code & DISCARDED_CHAR), buf}, |
964 |
| Level.WARNING); |
965 |
| } |
966 |
| |
967 |
| } |
968 |
| } |
969 |
| |
970 |
| |
971 |
| |
972 |
| |
973 |
| |
974 |
| |
975 |
| |
976 |
| |
977 |
566
| public void entityError(Lexer lexer, short code, String entity, int c)
|
978 |
| { |
979 |
566
| lexer.warnings++;
|
980 |
| |
981 |
566
| if (lexer.errors > lexer.configuration.showErrors)
|
982 |
| { |
983 |
0
| return;
|
984 |
| } |
985 |
| |
986 |
566
| if (lexer.configuration.showWarnings)
|
987 |
| { |
988 |
556
| switch (code)
|
989 |
| { |
990 |
201
| case MISSING_SEMICOLON :
|
991 |
201
| printMessage(code, lexer, "missing_semicolon", new Object[]{entity}, Level.WARNING);
|
992 |
201
| break;
|
993 |
0
| case MISSING_SEMICOLON_NCR :
|
994 |
0
| printMessage(code, lexer, "missing_semicolon_ncr", new Object[]{entity}, Level.WARNING);
|
995 |
0
| break;
|
996 |
336
| case UNKNOWN_ENTITY :
|
997 |
336
| printMessage(code, lexer, "unknown_entity", new Object[]{entity}, Level.WARNING);
|
998 |
336
| break;
|
999 |
17
| case UNESCAPED_AMPERSAND :
|
1000 |
17
| printMessage(code, lexer, "unescaped_ampersand", null, Level.WARNING);
|
1001 |
17
| break;
|
1002 |
2
| case APOS_UNDEFINED :
|
1003 |
2
| printMessage(code, lexer, "apos_undefined", null, Level.WARNING);
|
1004 |
2
| break;
|
1005 |
0
| default :
|
1006 |
| |
1007 |
0
| break;
|
1008 |
| } |
1009 |
| } |
1010 |
| } |
1011 |
| |
1012 |
| |
1013 |
| |
1014 |
| |
1015 |
| |
1016 |
| |
1017 |
| |
1018 |
| |
1019 |
507
| public void attrError(Lexer lexer, Node node, AttVal attribute, short code)
|
1020 |
| { |
1021 |
507
| if (code == UNEXPECTED_GT)
|
1022 |
| { |
1023 |
8
| lexer.errors++;
|
1024 |
| } |
1025 |
| else |
1026 |
| { |
1027 |
499
| lexer.warnings++;
|
1028 |
| } |
1029 |
| |
1030 |
507
| if (lexer.errors > lexer.configuration.showErrors)
|
1031 |
| { |
1032 |
139
| return;
|
1033 |
| } |
1034 |
| |
1035 |
368
| if (code == UNEXPECTED_GT)
|
1036 |
| { |
1037 |
6
| printMessage(code, lexer, "unexpected_gt", new Object[]{getTagName(node)}, Level.ERROR);
|
1038 |
| } |
1039 |
| |
1040 |
368
| if (!lexer.configuration.showWarnings)
|
1041 |
| { |
1042 |
3
| return;
|
1043 |
| } |
1044 |
| |
1045 |
365
| switch (code)
|
1046 |
| { |
1047 |
32
| case UNKNOWN_ATTRIBUTE :
|
1048 |
32
| printMessage(code, lexer, "unknown_attribute", new Object[]{attribute.attribute}, Level.WARNING);
|
1049 |
32
| break;
|
1050 |
| |
1051 |
73
| case MISSING_ATTRIBUTE :
|
1052 |
73
| printMessage(
|
1053 |
| code, |
1054 |
| lexer, |
1055 |
| "missing_attribute", |
1056 |
| new Object[]{getTagName(node), attribute.attribute}, |
1057 |
| Level.WARNING); |
1058 |
73
| break;
|
1059 |
| |
1060 |
4
| case MISSING_ATTR_VALUE :
|
1061 |
4
| printMessage(
|
1062 |
| code, |
1063 |
| lexer, |
1064 |
| "missing_attr_value", |
1065 |
| new Object[]{getTagName(node), attribute.attribute}, |
1066 |
| Level.WARNING); |
1067 |
4
| break;
|
1068 |
| |
1069 |
0
| case MISSING_IMAGEMAP :
|
1070 |
0
| printMessage(code, lexer, "missing_imagemap", new Object[]{getTagName(node)}, Level.WARNING);
|
1071 |
0
| lexer.badAccess |= MISSING_IMAGE_MAP;
|
1072 |
0
| break;
|
1073 |
| |
1074 |
30
| case BAD_ATTRIBUTE_VALUE :
|
1075 |
30
| printMessage(code, lexer, "bad_attribute_value", new Object[]{
|
1076 |
| getTagName(node), |
1077 |
| attribute.attribute, |
1078 |
| attribute.value}, Level.WARNING); |
1079 |
30
| break;
|
1080 |
| |
1081 |
2
| case XML_ID_SYNTAX :
|
1082 |
2
| printMessage(
|
1083 |
| code, |
1084 |
| lexer, |
1085 |
| "xml_id_sintax", |
1086 |
| new Object[]{getTagName(node), attribute.attribute}, |
1087 |
| Level.WARNING); |
1088 |
2
| break;
|
1089 |
| |
1090 |
1
| case XML_ATTRIBUTE_VALUE :
|
1091 |
1
| printMessage(
|
1092 |
| code, |
1093 |
| lexer, |
1094 |
| "xml_attribute_value", |
1095 |
| new Object[]{getTagName(node), attribute.attribute}, |
1096 |
| Level.WARNING); |
1097 |
1
| break;
|
1098 |
| |
1099 |
6
| case UNEXPECTED_QUOTEMARK :
|
1100 |
6
| printMessage(code, lexer, "unexpected_quotemark", new Object[]{getTagName(node)}, Level.WARNING);
|
1101 |
6
| break;
|
1102 |
| |
1103 |
9
| case MISSING_QUOTEMARK :
|
1104 |
9
| printMessage(code, lexer, "missing_quotemark", new Object[]{getTagName(node)}, Level.WARNING);
|
1105 |
9
| break;
|
1106 |
| |
1107 |
4
| case REPEATED_ATTRIBUTE :
|
1108 |
4
| printMessage(code, lexer, "repeated_attribute", new Object[]{
|
1109 |
| getTagName(node), |
1110 |
| attribute.value, |
1111 |
| attribute.attribute}, Level.WARNING); |
1112 |
4
| break;
|
1113 |
| |
1114 |
26
| case PROPRIETARY_ATTR_VALUE :
|
1115 |
26
| printMessage(
|
1116 |
| code, |
1117 |
| lexer, |
1118 |
| "proprietary_attr_value", |
1119 |
| new Object[]{getTagName(node), attribute.value}, |
1120 |
| Level.WARNING); |
1121 |
26
| break;
|
1122 |
| |
1123 |
10
| case PROPRIETARY_ATTRIBUTE :
|
1124 |
10
| printMessage(
|
1125 |
| code, |
1126 |
| lexer, |
1127 |
| "proprietary_attribute", |
1128 |
| new Object[]{getTagName(node), attribute.attribute}, |
1129 |
| Level.WARNING); |
1130 |
10
| break;
|
1131 |
| |
1132 |
1
| case UNEXPECTED_END_OF_FILE :
|
1133 |
| |
1134 |
1
| lexer.lines = lexer.in.getCurline();
|
1135 |
1
| lexer.columns = lexer.in.getCurcol();
|
1136 |
1
| printMessage(code, lexer, "unexpected_end_of_file", new Object[]{getTagName(node)}, Level.WARNING);
|
1137 |
1
| break;
|
1138 |
| |
1139 |
0
| case ID_NAME_MISMATCH :
|
1140 |
0
| printMessage(code, lexer, "id_name_mismatch", new Object[]{getTagName(node)}, Level.WARNING);
|
1141 |
0
| break;
|
1142 |
| |
1143 |
0
| case BACKSLASH_IN_URI :
|
1144 |
0
| printMessage(code, lexer, "backslash_in_uri", new Object[]{getTagName(node)}, Level.WARNING);
|
1145 |
0
| break;
|
1146 |
| |
1147 |
5
| case FIXED_BACKSLASH :
|
1148 |
5
| printMessage(code, lexer, "fixed_backslash", new Object[]{getTagName(node)}, Level.WARNING);
|
1149 |
5
| break;
|
1150 |
| |
1151 |
0
| case ILLEGAL_URI_REFERENCE :
|
1152 |
0
| printMessage(code, lexer, "illegal_uri_reference", new Object[]{getTagName(node)}, Level.WARNING);
|
1153 |
0
| break;
|
1154 |
| |
1155 |
129
| case ESCAPED_ILLEGAL_URI :
|
1156 |
129
| printMessage(code, lexer, "escaped_illegal_uri", new Object[]{getTagName(node)}, Level.WARNING);
|
1157 |
129
| break;
|
1158 |
| |
1159 |
8
| case NEWLINE_IN_URI :
|
1160 |
8
| printMessage(code, lexer, "newline_in_uri", new Object[]{getTagName(node)}, Level.WARNING);
|
1161 |
8
| break;
|
1162 |
| |
1163 |
15
| case ANCHOR_NOT_UNIQUE :
|
1164 |
15
| printMessage(
|
1165 |
| code, |
1166 |
| lexer, |
1167 |
| "anchor_not_unique", |
1168 |
| new Object[]{getTagName(node), attribute.value}, |
1169 |
| Level.WARNING); |
1170 |
15
| break;
|
1171 |
| |
1172 |
0
| case ENTITY_IN_ID :
|
1173 |
0
| printMessage(code, lexer, "entity_in_id", null, Level.WARNING);
|
1174 |
0
| break;
|
1175 |
| |
1176 |
1
| case JOINING_ATTRIBUTE :
|
1177 |
1
| printMessage(
|
1178 |
| code, |
1179 |
| lexer, |
1180 |
| "joining_attribute", |
1181 |
| new Object[]{getTagName(node), attribute.attribute}, |
1182 |
| Level.WARNING); |
1183 |
1
| break;
|
1184 |
| |
1185 |
1
| case UNEXPECTED_EQUALSIGN :
|
1186 |
1
| printMessage(code, lexer, "expected_equalsign", new Object[]{getTagName(node)}, Level.WARNING);
|
1187 |
1
| break;
|
1188 |
| |
1189 |
2
| case ATTR_VALUE_NOT_LCASE :
|
1190 |
2
| printMessage(code, lexer, "attr_value_not_lcase", new Object[]{
|
1191 |
| getTagName(node), |
1192 |
| attribute.value, |
1193 |
| attribute.attribute}, Level.WARNING); |
1194 |
2
| break;
|
1195 |
| |
1196 |
6
| default :
|
1197 |
6
| break;
|
1198 |
| } |
1199 |
| } |
1200 |
| |
1201 |
| |
1202 |
| |
1203 |
| |
1204 |
| |
1205 |
| |
1206 |
| |
1207 |
| |
1208 |
750
| public void warning(Lexer lexer, Node element, Node node, short code)
|
1209 |
| { |
1210 |
| |
1211 |
750
| TagTable tt = lexer.configuration.tt;
|
1212 |
750
| if (!((code == DISCARDING_UNEXPECTED) && lexer.badForm != 0))
|
1213 |
| { |
1214 |
741
| lexer.warnings++;
|
1215 |
| } |
1216 |
| |
1217 |
| |
1218 |
750
| if (lexer.errors > lexer.configuration.showErrors)
|
1219 |
| { |
1220 |
119
| return;
|
1221 |
| } |
1222 |
| |
1223 |
631
| if (lexer.configuration.showWarnings)
|
1224 |
| { |
1225 |
627
| switch (code)
|
1226 |
| { |
1227 |
18
| case MISSING_ENDTAG_FOR :
|
1228 |
18
| printMessage(code, lexer, "missing_endtag_for", new Object[]{element.element}, Level.WARNING);
|
1229 |
18
| break;
|
1230 |
| |
1231 |
69
| case MISSING_ENDTAG_BEFORE :
|
1232 |
69
| printMessage(
|
1233 |
| code, |
1234 |
| lexer, |
1235 |
| "missing_endtag_before", |
1236 |
| new Object[]{element.element, getTagName(node)}, |
1237 |
| Level.WARNING); |
1238 |
69
| break;
|
1239 |
| |
1240 |
104
| case DISCARDING_UNEXPECTED :
|
1241 |
104
| if (lexer.badForm == 0)
|
1242 |
| { |
1243 |
| |
1244 |
95
| printMessage(
|
1245 |
| code, |
1246 |
| lexer, |
1247 |
| "discarding_unexpected", |
1248 |
| new Object[]{getTagName(node)}, |
1249 |
| Level.WARNING); |
1250 |
| } |
1251 |
104
| break;
|
1252 |
| |
1253 |
22
| case NESTED_EMPHASIS :
|
1254 |
22
| printMessage(code, lexer, "nested_emphasis", new Object[]{getTagName(node)}, Level.INFO);
|
1255 |
22
| break;
|
1256 |
| |
1257 |
5
| case COERCE_TO_ENDTAG :
|
1258 |
5
| printMessage(code, lexer, "coerce_to_endtag", new Object[]{element.element}, Level.INFO);
|
1259 |
5
| break;
|
1260 |
| |
1261 |
4
| case NON_MATCHING_ENDTAG :
|
1262 |
4
| printMessage(
|
1263 |
| code, |
1264 |
| lexer, |
1265 |
| "non_matching_endtag", |
1266 |
| new Object[]{getTagName(node), element.element}, |
1267 |
| Level.WARNING); |
1268 |
4
| break;
|
1269 |
| |
1270 |
31
| case TAG_NOT_ALLOWED_IN :
|
1271 |
31
| printMessage(
|
1272 |
| code, |
1273 |
| lexer, |
1274 |
| "tag_not_allowed_in", |
1275 |
| new Object[]{getTagName(node), element.element}, |
1276 |
| Level.WARNING); |
1277 |
31
| break;
|
1278 |
| |
1279 |
2
| case DOCTYPE_AFTER_TAGS :
|
1280 |
2
| printMessage(code, lexer, "doctype_after_tags", null, Level.WARNING);
|
1281 |
2
| break;
|
1282 |
| |
1283 |
10
| case MISSING_STARTTAG :
|
1284 |
10
| printMessage(code, lexer, "missing_starttag", new Object[]{node.element}, Level.WARNING);
|
1285 |
10
| break;
|
1286 |
| |
1287 |
1
| case UNEXPECTED_ENDTAG :
|
1288 |
1
| if (element != null)
|
1289 |
| { |
1290 |
0
| printMessage(
|
1291 |
| code, |
1292 |
| lexer, |
1293 |
| "unexpected_endtag_in", |
1294 |
| new Object[]{node.element, element.element}, |
1295 |
| Level.WARNING); |
1296 |
| } |
1297 |
| else |
1298 |
| { |
1299 |
1
| printMessage(code, lexer, "unexpected_endtag", new Object[]{node.element}, Level.WARNING);
|
1300 |
| } |
1301 |
1
| break;
|
1302 |
| |
1303 |
0
| case TOO_MANY_ELEMENTS :
|
1304 |
0
| if (element != null)
|
1305 |
| { |
1306 |
0
| printMessage(
|
1307 |
| code, |
1308 |
| lexer, |
1309 |
| "too_many_elements_in", |
1310 |
| new Object[]{node.element, element.element}, |
1311 |
| Level.WARNING); |
1312 |
| } |
1313 |
| else |
1314 |
| { |
1315 |
0
| printMessage(code, lexer, "too_many_elements", new Object[]{node.element}, Level.WARNING);
|
1316 |
| } |
1317 |
0
| break;
|
1318 |
| |
1319 |
0
| case USING_BR_INPLACE_OF :
|
1320 |
0
| printMessage(code, lexer, "using_br_inplace_of", new Object[]{getTagName(node)}, Level.WARNING);
|
1321 |
0
| break;
|
1322 |
| |
1323 |
95
| case INSERTING_TAG :
|
1324 |
95
| printMessage(code, lexer, "inserting_tag", new Object[]{node.element}, Level.WARNING);
|
1325 |
95
| break;
|
1326 |
| |
1327 |
0
| case CANT_BE_NESTED :
|
1328 |
0
| printMessage(code, lexer, "cant_be_nested", new Object[]{getTagName(node)}, Level.WARNING);
|
1329 |
0
| break;
|
1330 |
| |
1331 |
22
| case PROPRIETARY_ELEMENT :
|
1332 |
22
| printMessage(code, lexer, "proprietary_element", new Object[]{getTagName(node)}, Level.WARNING);
|
1333 |
| |
1334 |
22
| if (node.tag == tt.tagLayer)
|
1335 |
| { |
1336 |
0
| lexer.badLayout |= USING_LAYER;
|
1337 |
| } |
1338 |
22
| else if (node.tag == tt.tagSpacer)
|
1339 |
| { |
1340 |
0
| lexer.badLayout |= USING_SPACER;
|
1341 |
| } |
1342 |
22
| else if (node.tag == tt.tagNobr)
|
1343 |
| { |
1344 |
1
| lexer.badLayout |= USING_NOBR;
|
1345 |
| } |
1346 |
22
| break;
|
1347 |
| |
1348 |
16
| case OBSOLETE_ELEMENT :
|
1349 |
16
| if (element.tag != null && (element.tag.model & Dict.CM_OBSOLETE) != 0)
|
1350 |
| { |
1351 |
0
| printMessage(code, lexer, "obsolete_element", new Object[]{
|
1352 |
| getTagName(element), |
1353 |
| getTagName(node)}, Level.WARNING); |
1354 |
| } |
1355 |
| else |
1356 |
| { |
1357 |
16
| printMessage(code, lexer, "replacing_element", new Object[]{
|
1358 |
| getTagName(element), |
1359 |
| getTagName(node)}, Level.WARNING); |
1360 |
| } |
1361 |
16
| break;
|
1362 |
| |
1363 |
4
| case UNESCAPED_ELEMENT :
|
1364 |
4
| printMessage(code, lexer, "unescaped_element", new Object[]{getTagName(element)}, Level.WARNING);
|
1365 |
4
| break;
|
1366 |
| |
1367 |
75
| case TRIM_EMPTY_ELEMENT :
|
1368 |
75
| printMessage(code, lexer, "trim_empty_element", new Object[]{getTagName(element)}, Level.WARNING);
|
1369 |
75
| break;
|
1370 |
| |
1371 |
8
| case MISSING_TITLE_ELEMENT :
|
1372 |
8
| printMessage(code, lexer, "missing_title_element", null, Level.WARNING);
|
1373 |
8
| break;
|
1374 |
| |
1375 |
1
| case ILLEGAL_NESTING :
|
1376 |
1
| printMessage(code, lexer, "illegal_nesting", new Object[]{getTagName(element)}, Level.WARNING);
|
1377 |
1
| break;
|
1378 |
| |
1379 |
1
| case NOFRAMES_CONTENT :
|
1380 |
1
| printMessage(code, lexer, "noframes_content", new Object[]{getTagName(node)}, Level.WARNING);
|
1381 |
1
| break;
|
1382 |
| |
1383 |
8
| case INCONSISTENT_VERSION :
|
1384 |
8
| printMessage(code, lexer, "inconsistent_version", null, Level.WARNING);
|
1385 |
8
| break;
|
1386 |
| |
1387 |
0
| case MALFORMED_DOCTYPE :
|
1388 |
0
| printMessage(code, lexer, "malformed_doctype", null, Level.WARNING);
|
1389 |
0
| break;
|
1390 |
| |
1391 |
4
| case CONTENT_AFTER_BODY :
|
1392 |
4
| printMessage(code, lexer, "content_after_body", null, Level.WARNING);
|
1393 |
4
| break;
|
1394 |
| |
1395 |
9
| case MALFORMED_COMMENT :
|
1396 |
9
| printMessage(code, lexer, "malformed_comment", null, Level.WARNING);
|
1397 |
9
| break;
|
1398 |
| |
1399 |
0
| case BAD_COMMENT_CHARS :
|
1400 |
0
| printMessage(code, lexer, "bad_comment_chars", null, Level.WARNING);
|
1401 |
0
| break;
|
1402 |
| |
1403 |
0
| case BAD_XML_COMMENT :
|
1404 |
0
| printMessage(code, lexer, "bad_xml_comment", null, Level.WARNING);
|
1405 |
0
| break;
|
1406 |
| |
1407 |
14
| case BAD_CDATA_CONTENT :
|
1408 |
14
| printMessage(code, lexer, "bad_cdata_content", null, Level.WARNING);
|
1409 |
14
| break;
|
1410 |
| |
1411 |
0
| case INCONSISTENT_NAMESPACE :
|
1412 |
0
| printMessage(code, lexer, "inconsistent_namespace", null, Level.WARNING);
|
1413 |
0
| break;
|
1414 |
| |
1415 |
0
| case DTYPE_NOT_UPPER_CASE :
|
1416 |
0
| printMessage(code, lexer, "dtype_not_upper_case", null, Level.WARNING);
|
1417 |
0
| break;
|
1418 |
| |
1419 |
0
| case UNEXPECTED_END_OF_FILE :
|
1420 |
| |
1421 |
0
| lexer.lines = lexer.in.getCurline();
|
1422 |
0
| lexer.columns = lexer.in.getCurcol();
|
1423 |
0
| printMessage(
|
1424 |
| code, |
1425 |
| lexer, |
1426 |
| "unexpected_end_of_file", |
1427 |
| new Object[]{getTagName(element)}, |
1428 |
| Level.WARNING); |
1429 |
0
| break;
|
1430 |
| |
1431 |
1
| case NESTED_QUOTATION :
|
1432 |
1
| printMessage(code, lexer, "nested_quotation", null, Level.WARNING);
|
1433 |
1
| break;
|
1434 |
| |
1435 |
0
| case ELEMENT_NOT_EMPTY :
|
1436 |
0
| printMessage(code, lexer, "element_not_empty", new Object[]{getTagName(element)}, Level.WARNING);
|
1437 |
0
| break;
|
1438 |
| |
1439 |
103
| case MISSING_DOCTYPE :
|
1440 |
103
| printMessage(code, lexer, "missing_doctype", null, Level.WARNING);
|
1441 |
103
| break;
|
1442 |
| |
1443 |
0
| default :
|
1444 |
0
| break;
|
1445 |
| } |
1446 |
| } |
1447 |
| |
1448 |
631
| if ((code == DISCARDING_UNEXPECTED) && lexer.badForm != 0)
|
1449 |
| { |
1450 |
| |
1451 |
9
| printMessage(code, lexer, "discarding_unexpected", new Object[]{getTagName(node)}, Level.ERROR);
|
1452 |
| } |
1453 |
| |
1454 |
| } |
1455 |
| |
1456 |
| |
1457 |
| |
1458 |
| |
1459 |
| |
1460 |
| |
1461 |
| |
1462 |
| |
1463 |
28
| public void error(Lexer lexer, Node element, Node node, short code)
|
1464 |
| { |
1465 |
28
| lexer.errors++;
|
1466 |
| |
1467 |
| |
1468 |
28
| if (lexer.errors > lexer.configuration.showErrors)
|
1469 |
| { |
1470 |
12
| return;
|
1471 |
| } |
1472 |
| |
1473 |
16
| if (code == SUSPECTED_MISSING_QUOTE)
|
1474 |
| { |
1475 |
0
| printMessage(code, lexer, "suspected_missing_quote", null, Level.ERROR);
|
1476 |
| } |
1477 |
16
| else if (code == DUPLICATE_FRAMESET)
|
1478 |
| { |
1479 |
0
| printMessage(code, lexer, "duplicate_frameset", null, Level.ERROR);
|
1480 |
| } |
1481 |
16
| else if (code == UNKNOWN_ELEMENT)
|
1482 |
| { |
1483 |
15
| printMessage(code, lexer, "unknown_element", new Object[]{getTagName(node)}, Level.ERROR);
|
1484 |
| } |
1485 |
1
| else if (code == UNEXPECTED_ENDTAG)
|
1486 |
| { |
1487 |
1
| if (element != null)
|
1488 |
| { |
1489 |
1
| printMessage(
|
1490 |
| code, |
1491 |
| lexer, |
1492 |
| "unexpected_endtag_in", |
1493 |
| new Object[]{node.element, element.element}, |
1494 |
| Level.ERROR); |
1495 |
| } |
1496 |
| else |
1497 |
| { |
1498 |
0
| printMessage(code, lexer, "unexpected_endtag", new Object[]{node.element}, Level.ERROR);
|
1499 |
| } |
1500 |
| } |
1501 |
| } |
1502 |
| |
1503 |
| |
1504 |
| |
1505 |
| |
1506 |
| |
1507 |
231
| public void errorSummary(Lexer lexer)
|
1508 |
| { |
1509 |
| |
1510 |
231
| if ((lexer.badAccess & (USING_FRAMES | USING_NOFRAMES)) != 0)
|
1511 |
| { |
1512 |
8
| if (!(((lexer.badAccess & USING_FRAMES) != 0) && ((lexer.badAccess & USING_NOFRAMES) == 0)))
|
1513 |
| { |
1514 |
5
| lexer.badAccess &= ~(USING_FRAMES | USING_NOFRAMES);
|
1515 |
| } |
1516 |
| } |
1517 |
231
| if (lexer.badChars != 0)
|
1518 |
| { |
1519 |
7
| if ((lexer.badChars & VENDOR_SPECIFIC_CHARS) != 0)
|
1520 |
| { |
1521 |
7
| int encodingChoiche = 0;
|
1522 |
| |
1523 |
7
| if ("Cp1252".equals(lexer.configuration.getInCharEncodingName()))
|
1524 |
| { |
1525 |
0
| encodingChoiche = 1;
|
1526 |
| } |
1527 |
7
| else if ("MacRoman".equals(lexer.configuration.getInCharEncodingName()))
|
1528 |
| { |
1529 |
0
| encodingChoiche = 2;
|
1530 |
| } |
1531 |
| |
1532 |
7
| printMessage(VENDOR_SPECIFIC_CHARS, lexer, "vendor_specific_chars_summary", new Object[]{new Integer(
|
1533 |
| encodingChoiche)}, Level.SUMMARY); |
1534 |
| } |
1535 |
| |
1536 |
7
| if ((lexer.badChars & INVALID_SGML_CHARS) != 0 || (lexer.badChars & INVALID_NCR) != 0)
|
1537 |
| { |
1538 |
7
| int encodingChoiche = 0;
|
1539 |
| |
1540 |
7
| if ("Cp1252".equals(lexer.configuration.getInCharEncodingName()))
|
1541 |
| { |
1542 |
0
| encodingChoiche = 1;
|
1543 |
| } |
1544 |
7
| else if ("MacRoman".equals(lexer.configuration.getInCharEncodingName()))
|
1545 |
| { |
1546 |
0
| encodingChoiche = 2;
|
1547 |
| } |
1548 |
| |
1549 |
7
| printMessage(INVALID_SGML_CHARS, lexer, "invalid_sgml_chars_summary", new Object[]{new Integer(
|
1550 |
| encodingChoiche)}, Level.SUMMARY); |
1551 |
| } |
1552 |
| |
1553 |
7
| if ((lexer.badChars & INVALID_UTF8) != 0)
|
1554 |
| { |
1555 |
7
| printMessage(INVALID_UTF8, lexer, "invalid_utf8_summary", null, Level.SUMMARY);
|
1556 |
| } |
1557 |
| |
1558 |
7
| if ((lexer.badChars & INVALID_UTF16) != 0)
|
1559 |
| { |
1560 |
7
| printMessage(INVALID_UTF16, lexer, "invalid_utf16_summary", null, Level.SUMMARY);
|
1561 |
| } |
1562 |
| |
1563 |
7
| if ((lexer.badChars & INVALID_URI) != 0)
|
1564 |
| { |
1565 |
7
| printMessage(INVALID_URI, lexer, "invaliduri_summary", null, Level.SUMMARY);
|
1566 |
| } |
1567 |
| } |
1568 |
| |
1569 |
231
| if (lexer.badForm != 0)
|
1570 |
| { |
1571 |
3
| printMessage(BADFORM_SUMMARY, lexer, "badform_summary", null, Level.SUMMARY);
|
1572 |
| } |
1573 |
| |
1574 |
231
| if (lexer.badAccess != 0)
|
1575 |
| { |
1576 |
19
| if ((lexer.badAccess & MISSING_SUMMARY) != 0)
|
1577 |
| { |
1578 |
12
| printMessage(MISSING_SUMMARY, lexer, "badaccess_missing_summary", null, Level.SUMMARY);
|
1579 |
| } |
1580 |
| |
1581 |
19
| if ((lexer.badAccess & MISSING_IMAGE_ALT) != 0)
|
1582 |
| { |
1583 |
7
| printMessage(MISSING_IMAGE_ALT, lexer, "badaccess_missing_image_alt", null, Level.SUMMARY);
|
1584 |
| } |
1585 |
| |
1586 |
19
| if ((lexer.badAccess & MISSING_IMAGE_MAP) != 0)
|
1587 |
| { |
1588 |
0
| printMessage(MISSING_IMAGE_MAP, lexer, "badaccess_missing_image_map", null, Level.SUMMARY);
|
1589 |
| } |
1590 |
| |
1591 |
19
| if ((lexer.badAccess & MISSING_LINK_ALT) != 0)
|
1592 |
| { |
1593 |
0
| printMessage(MISSING_LINK_ALT, lexer, "badaccess_missing_link_alt", null, Level.SUMMARY);
|
1594 |
| } |
1595 |
| |
1596 |
19
| if (((lexer.badAccess & USING_FRAMES) != 0) && ((lexer.badAccess & USING_NOFRAMES) == 0))
|
1597 |
| { |
1598 |
3
| printMessage(USING_FRAMES, lexer, "badaccess_frames", null, Level.SUMMARY);
|
1599 |
| } |
1600 |
| |
1601 |
19
| printMessage(BADACCESS_SUMMARY, lexer, "badaccess_summary", new Object[]{ACCESS_URL}, Level.SUMMARY);
|
1602 |
| } |
1603 |
| |
1604 |
231
| if (lexer.badLayout != 0)
|
1605 |
| { |
1606 |
21
| if ((lexer.badLayout & USING_LAYER) != 0)
|
1607 |
| { |
1608 |
0
| printMessage(USING_LAYER, lexer, "badlayout_using_layer", null, Level.SUMMARY);
|
1609 |
| } |
1610 |
| |
1611 |
21
| if ((lexer.badLayout & USING_SPACER) != 0)
|
1612 |
| { |
1613 |
0
| printMessage(USING_SPACER, lexer, "badlayout_using_spacer", null, Level.SUMMARY);
|
1614 |
| } |
1615 |
| |
1616 |
21
| if ((lexer.badLayout & USING_FONT) != 0)
|
1617 |
| { |
1618 |
20
| printMessage(USING_FONT, lexer, "badlayout_using_font", null, Level.SUMMARY);
|
1619 |
| } |
1620 |
| |
1621 |
21
| if ((lexer.badLayout & USING_NOBR) != 0)
|
1622 |
| { |
1623 |
1
| printMessage(USING_NOBR, lexer, "badlayout_using_nobr", null, Level.SUMMARY);
|
1624 |
| } |
1625 |
| |
1626 |
21
| if ((lexer.badLayout & USING_BODY) != 0)
|
1627 |
| { |
1628 |
0
| printMessage(USING_BODY, lexer, "badlayout_using_body", null, Level.SUMMARY);
|
1629 |
| } |
1630 |
| } |
1631 |
| } |
1632 |
| |
1633 |
| |
1634 |
| |
1635 |
| |
1636 |
| |
1637 |
| |
1638 |
0
| public void unknownOption(PrintWriter errout, char c)
|
1639 |
| { |
1640 |
0
| printMessage(errout, "unrecognized_option", new Object[]{new String(new char[]{c})}, Level.ERROR);
|
1641 |
| } |
1642 |
| |
1643 |
| |
1644 |
| |
1645 |
| |
1646 |
| |
1647 |
| |
1648 |
0
| public void unknownFile(PrintWriter errout, String file)
|
1649 |
| { |
1650 |
0
| printMessage(errout, "unknown_file", new Object[]{"Tidy", file}, Level.ERROR);
|
1651 |
| } |
1652 |
| |
1653 |
| |
1654 |
| |
1655 |
| |
1656 |
| |
1657 |
14
| public void needsAuthorIntervention(PrintWriter errout)
|
1658 |
| { |
1659 |
14
| printMessage(errout, "needs_author_intervention", null, Level.SUMMARY);
|
1660 |
| } |
1661 |
| |
1662 |
| |
1663 |
| |
1664 |
| |
1665 |
| |
1666 |
0
| public void missingBody(PrintWriter errout)
|
1667 |
| { |
1668 |
0
| printMessage(errout, "missing_body", null, Level.ERROR);
|
1669 |
| } |
1670 |
| |
1671 |
| |
1672 |
| |
1673 |
| |
1674 |
| |
1675 |
| |
1676 |
1
| public void reportNumberOfSlides(PrintWriter errout, int count)
|
1677 |
| { |
1678 |
1
| printMessage(errout, "slides_found", new Object[]{new Integer(count)}, Level.SUMMARY);
|
1679 |
| } |
1680 |
| |
1681 |
| |
1682 |
| |
1683 |
| |
1684 |
| |
1685 |
0
| public void generalInfo(PrintWriter errout)
|
1686 |
| { |
1687 |
0
| printMessage(errout, "general_info", null, Level.SUMMARY);
|
1688 |
| } |
1689 |
| |
1690 |
| |
1691 |
| |
1692 |
| |
1693 |
| |
1694 |
233
| public void helloMessage(PrintWriter errout)
|
1695 |
| { |
1696 |
233
| printMessage(errout, "hello_message", new Object[]{Report.RELEASE_DATE, this.currentFile}, Level.SUMMARY);
|
1697 |
| } |
1698 |
| |
1699 |
| |
1700 |
| |
1701 |
| |
1702 |
| |
1703 |
238
| public void setFilename(String filename)
|
1704 |
| { |
1705 |
238
| this.currentFile = filename;
|
1706 |
| } |
1707 |
| |
1708 |
| |
1709 |
| |
1710 |
| |
1711 |
| |
1712 |
| |
1713 |
| |
1714 |
| |
1715 |
214
| public void reportVersion(PrintWriter errout, Lexer lexer, String filename, Node doctype)
|
1716 |
| { |
1717 |
214
| int i, c;
|
1718 |
214
| int state = 0;
|
1719 |
214
| String vers = lexer.htmlVersionName();
|
1720 |
214
| int[] cc = new int[1];
|
1721 |
| |
1722 |
| |
1723 |
214
| lexer.lines = 1;
|
1724 |
214
| lexer.columns = 1;
|
1725 |
| |
1726 |
214
| if (doctype != null)
|
1727 |
| { |
1728 |
| |
1729 |
113
| StringBuffer doctypeBuffer = new StringBuffer();
|
1730 |
113
| for (i = doctype.start; i < doctype.end; ++i)
|
1731 |
| { |
1732 |
9145
| c = doctype.textarray[i];
|
1733 |
| |
1734 |
| |
1735 |
9145
| if (c < 0)
|
1736 |
| { |
1737 |
0
| i += PPrint.getUTF8(doctype.textarray, i, cc);
|
1738 |
0
| c = cc[0];
|
1739 |
| } |
1740 |
| |
1741 |
9145
| if (c == '"')
|
1742 |
| { |
1743 |
378
| ++state;
|
1744 |
| } |
1745 |
8767
| else if (state == 1)
|
1746 |
| { |
1747 |
3701
| doctypeBuffer.append((char) c);
|
1748 |
| } |
1749 |
| } |
1750 |
| |
1751 |
113
| printMessage(
|
1752 |
| DOCTYPE_GIVEN_SUMMARY, |
1753 |
| lexer, |
1754 |
| "doctype_given", |
1755 |
| new Object[]{filename, doctypeBuffer}, |
1756 |
| Level.SUMMARY); |
1757 |
| } |
1758 |
| |
1759 |
214
| printMessage(REPORT_VERSION_SUMMARY, lexer, "report_version", new Object[]{
|
1760 |
| filename, |
1761 |
214
| (vers != null ? vers : "HTML proprietary")}, Level.SUMMARY);
|
1762 |
| } |
1763 |
| |
1764 |
| |
1765 |
| |
1766 |
| |
1767 |
| |
1768 |
| |
1769 |
231
| public void reportNumWarnings(PrintWriter errout, Lexer lexer)
|
1770 |
| { |
1771 |
231
| if (lexer.warnings > 0 || lexer.errors > 0)
|
1772 |
| { |
1773 |
159
| printMessage(
|
1774 |
| errout, |
1775 |
| "num_warnings", |
1776 |
| new Object[]{new Integer(lexer.warnings), new Integer(lexer.errors)}, |
1777 |
| Level.SUMMARY); |
1778 |
| } |
1779 |
| else |
1780 |
| { |
1781 |
72
| printMessage(errout, "no_warnings", null, Level.SUMMARY);
|
1782 |
| } |
1783 |
| } |
1784 |
| |
1785 |
| |
1786 |
| |
1787 |
| |
1788 |
| |
1789 |
0
| public void helpText(PrintWriter out)
|
1790 |
| { |
1791 |
0
| printMessage(out, "help_text", new Object[]{"Tidy", RELEASE_DATE}, Level.SUMMARY);
|
1792 |
| } |
1793 |
| |
1794 |
| |
1795 |
| |
1796 |
| |
1797 |
| |
1798 |
2
| public void badTree(PrintWriter errout)
|
1799 |
| { |
1800 |
2
| printMessage(errout, "bad_tree", null, Level.ERROR);
|
1801 |
| } |
1802 |
| |
1803 |
| |
1804 |
| |
1805 |
| |
1806 |
| |
1807 |
222
| public void addMessageListener(TidyMessageListener listener)
|
1808 |
| { |
1809 |
222
| this.listener = listener;
|
1810 |
| } |
1811 |
| } |