Source Code Cross Referenced for Report.java in  » Groupware » hipergate » org » w3c » tidy » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Groupware » hipergate » org.w3c.tidy 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


0001:        /*
0002:         * @(#)Report.java   1.11 2000/08/16
0003:         *
0004:         */
0005:
0006:        package org.w3c.tidy;
0007:
0008:        /**
0009:         *
0010:         * Error/informational message reporter.
0011:         *
0012:         * You should only need to edit the file TidyMessages.properties
0013:         * to localize HTML tidy.
0014:         *
0015:         * (c) 1998-2000 (W3C) MIT, INRIA, Keio University
0016:         * Derived from <a href="http://www.w3.org/People/Raggett/tidy">
0017:         * HTML Tidy Release 4 Aug 2000</a>
0018:         *
0019:         * @author  Dave Raggett <dsr@w3.org>
0020:         * @author  Andy Quick <ac.quick@sympatico.ca> (translation to Java)
0021:         * @version 1.0, 1999/05/22
0022:         * @version 1.0.1, 1999/05/29
0023:         * @version 1.1, 1999/06/18 Java Bean
0024:         * @version 1.2, 1999/07/10 Tidy Release 7 Jul 1999
0025:         * @version 1.3, 1999/07/30 Tidy Release 26 Jul 1999
0026:         * @version 1.4, 1999/09/04 DOM support
0027:         * @version 1.5, 1999/10/23 Tidy Release 27 Sep 1999
0028:         * @version 1.6, 1999/11/01 Tidy Release 22 Oct 1999
0029:         * @version 1.7, 1999/12/06 Tidy Release 30 Nov 1999
0030:         * @version 1.8, 2000/01/22 Tidy Release 13 Jan 2000
0031:         * @version 1.9, 2000/06/03 Tidy Release 30 Apr 2000
0032:         * @version 1.10, 2000/07/22 Tidy Release 8 Jul 2000
0033:         * @version 1.11, 2000/08/16 Tidy Release 4 Aug 2000
0034:         */
0035:
0036:        import java.text.MessageFormat;
0037:        import java.util.ResourceBundle;
0038:        import java.util.MissingResourceException;
0039:        import java.io.PrintWriter;
0040:
0041:        public class Report {
0042:
0043:            /* used to point to Web Accessibility Guidelines */
0044:            public static final String ACCESS_URL = "http://www.w3.org/WAI/GL";
0045:
0046:            public static final String RELEASE_DATE = "4th August 2000";
0047:
0048:            public static String currentFile; /* sasdjb 01May00 for GNU Emacs error parsing */
0049:
0050:            /* error codes for entities */
0051:
0052:            public static final short MISSING_SEMICOLON = 1;
0053:            public static final short UNKNOWN_ENTITY = 2;
0054:            public static final short UNESCAPED_AMPERSAND = 3;
0055:
0056:            /* error codes for element messages */
0057:
0058:            public static final short MISSING_ENDTAG_FOR = 1;
0059:            public static final short MISSING_ENDTAG_BEFORE = 2;
0060:            public static final short DISCARDING_UNEXPECTED = 3;
0061:            public static final short NESTED_EMPHASIS = 4;
0062:            public static final short NON_MATCHING_ENDTAG = 5;
0063:            public static final short TAG_NOT_ALLOWED_IN = 6;
0064:            public static final short MISSING_STARTTAG = 7;
0065:            public static final short UNEXPECTED_ENDTAG = 8;
0066:            public static final short USING_BR_INPLACE_OF = 9;
0067:            public static final short INSERTING_TAG = 10;
0068:            public static final short SUSPECTED_MISSING_QUOTE = 11;
0069:            public static final short MISSING_TITLE_ELEMENT = 12;
0070:            public static final short DUPLICATE_FRAMESET = 13;
0071:            public static final short CANT_BE_NESTED = 14;
0072:            public static final short OBSOLETE_ELEMENT = 15;
0073:            public static final short PROPRIETARY_ELEMENT = 16;
0074:            public static final short UNKNOWN_ELEMENT = 17;
0075:            public static final short TRIM_EMPTY_ELEMENT = 18;
0076:            public static final short COERCE_TO_ENDTAG = 19;
0077:            public static final short ILLEGAL_NESTING = 20;
0078:            public static final short NOFRAMES_CONTENT = 21;
0079:            public static final short CONTENT_AFTER_BODY = 22;
0080:            public static final short INCONSISTENT_VERSION = 23;
0081:            public static final short MALFORMED_COMMENT = 24;
0082:            public static final short BAD_COMMENT_CHARS = 25;
0083:            public static final short BAD_XML_COMMENT = 26;
0084:            public static final short BAD_CDATA_CONTENT = 27;
0085:            public static final short INCONSISTENT_NAMESPACE = 28;
0086:            public static final short DOCTYPE_AFTER_TAGS = 29;
0087:            public static final short MALFORMED_DOCTYPE = 30;
0088:            public static final short UNEXPECTED_END_OF_FILE = 31;
0089:            public static final short DTYPE_NOT_UPPER_CASE = 32;
0090:            public static final short TOO_MANY_ELEMENTS = 33;
0091:
0092:            /* error codes used for attribute messages */
0093:
0094:            public static final short UNKNOWN_ATTRIBUTE = 1;
0095:            public static final short MISSING_ATTRIBUTE = 2;
0096:            public static final short MISSING_ATTR_VALUE = 3;
0097:            public static final short BAD_ATTRIBUTE_VALUE = 4;
0098:            public static final short UNEXPECTED_GT = 5;
0099:            public static final short PROPRIETARY_ATTR_VALUE = 6;
0100:            public static final short REPEATED_ATTRIBUTE = 7;
0101:            public static final short MISSING_IMAGEMAP = 8;
0102:            public static final short XML_ATTRIBUTE_VALUE = 9;
0103:            public static final short UNEXPECTED_QUOTEMARK = 10;
0104:            public static final short ID_NAME_MISMATCH = 11;
0105:
0106:            /* accessibility flaws */
0107:
0108:            public static final short MISSING_IMAGE_ALT = 1;
0109:            public static final short MISSING_LINK_ALT = 2;
0110:            public static final short MISSING_SUMMARY = 4;
0111:            public static final short MISSING_IMAGE_MAP = 8;
0112:            public static final short USING_FRAMES = 16;
0113:            public static final short USING_NOFRAMES = 32;
0114:
0115:            /* presentation flaws */
0116:
0117:            public static final short USING_SPACER = 1;
0118:            public static final short USING_LAYER = 2;
0119:            public static final short USING_NOBR = 4;
0120:            public static final short USING_FONT = 8;
0121:            public static final short USING_BODY = 16;
0122:
0123:            /* character encoding errors */
0124:            public static final short WINDOWS_CHARS = 1;
0125:            public static final short NON_ASCII = 2;
0126:            public static final short FOUND_UTF16 = 4;
0127:
0128:            private static short optionerrors;
0129:
0130:            private static ResourceBundle res = null;
0131:
0132:            static {
0133:                try {
0134:                    res = ResourceBundle.getBundle("org/w3c/tidy/TidyMessages");
0135:                } catch (MissingResourceException e) {
0136:                    throw new Error(e.toString());
0137:                }
0138:            }
0139:
0140:            public static void tidyPrint(PrintWriter p, String msg) {
0141:                p.print(msg);
0142:            }
0143:
0144:            public static void tidyPrintln(PrintWriter p, String msg) {
0145:                p.println(msg);
0146:            }
0147:
0148:            public static void tidyPrintln(PrintWriter p) {
0149:                p.println();
0150:            }
0151:
0152:            public static void showVersion(PrintWriter p) {
0153:                tidyPrintln(p, "Java HTML Tidy release date: " + RELEASE_DATE);
0154:                tidyPrintln(p,
0155:                        "See http://www.w3.org/People/Raggett for details");
0156:            }
0157:
0158:            public static void tag(Lexer lexer, Node tag) {
0159:                if (tag != null) {
0160:                    if (tag.type == Node.StartTag)
0161:                        tidyPrint(lexer.errout, "<" + tag.element + ">");
0162:                    else if (tag.type == Node.EndTag)
0163:                        tidyPrint(lexer.errout, "</" + tag.element + ">");
0164:                    else if (tag.type == Node.DocTypeTag)
0165:                        tidyPrint(lexer.errout, "<!DOCTYPE>");
0166:                    else if (tag.type == Node.TextNode)
0167:                        tidyPrint(lexer.errout, "plain text");
0168:                    else
0169:                        tidyPrint(lexer.errout, tag.element);
0170:                }
0171:            }
0172:
0173:            /* lexer is not defined when this is called */
0174:            public static void unknownOption(String option) {
0175:                optionerrors++;
0176:                try {
0177:                    System.err.println(MessageFormat.format(res
0178:                            .getString("unknown_option"),
0179:                            new Object[] { option }));
0180:                } catch (MissingResourceException e) {
0181:                    System.err.println(e.toString());
0182:                }
0183:            }
0184:
0185:            /* lexer is not defined when this is called */
0186:            public static void badArgument(String option) {
0187:                optionerrors++;
0188:                try {
0189:                    System.err.println(MessageFormat
0190:                            .format(res.getString("bad_argument"),
0191:                                    new Object[] { option }));
0192:                } catch (MissingResourceException e) {
0193:                    System.err.println(e.toString());
0194:                }
0195:            }
0196:
0197:            public static void position(Lexer lexer) {
0198:                try {
0199:                    /* Change formatting to be parsable by GNU Emacs */
0200:                    if (lexer.configuration.Emacs) {
0201:                        tidyPrint(lexer.errout, MessageFormat.format(res
0202:                                .getString("emacs_format"), new Object[] {
0203:                                currentFile, new Integer(lexer.lines),
0204:                                new Integer(lexer.columns) }));
0205:                        tidyPrint(lexer.errout, " ");
0206:                    } else /* traditional format */
0207:                    {
0208:                        tidyPrint(lexer.errout, MessageFormat.format(res
0209:                                .getString("line_column"), new Object[] {
0210:                                new Integer(lexer.lines),
0211:                                new Integer(lexer.columns) }));
0212:                    }
0213:                } catch (MissingResourceException e) {
0214:                    lexer.errout.println(e.toString());
0215:                }
0216:            }
0217:
0218:            public static void encodingError(Lexer lexer, short code, int c) {
0219:                lexer.warnings++;
0220:
0221:                if (lexer.configuration.ShowWarnings) {
0222:                    position(lexer);
0223:
0224:                    if (code == WINDOWS_CHARS) {
0225:                        lexer.badChars |= WINDOWS_CHARS;
0226:                        try {
0227:                            tidyPrint(lexer.errout, MessageFormat.format(res
0228:                                    .getString("illegal_char"),
0229:                                    new Object[] { new Integer(c) }));
0230:                        } catch (MissingResourceException e) {
0231:                            lexer.errout.println(e.toString());
0232:                        }
0233:                    }
0234:
0235:                    tidyPrintln(lexer.errout);
0236:                }
0237:            }
0238:
0239:            public static void entityError(Lexer lexer, short code,
0240:                    String entity, int c) {
0241:                lexer.warnings++;
0242:
0243:                if (lexer.configuration.ShowWarnings) {
0244:                    position(lexer);
0245:
0246:                    if (code == MISSING_SEMICOLON) {
0247:                        try {
0248:                            tidyPrint(lexer.errout, MessageFormat.format(res
0249:                                    .getString("missing_semicolon"),
0250:                                    new Object[] { entity }));
0251:                        } catch (MissingResourceException e) {
0252:                            lexer.errout.println(e.toString());
0253:                        }
0254:                    } else if (code == UNKNOWN_ENTITY) {
0255:                        try {
0256:                            tidyPrint(lexer.errout, MessageFormat.format(res
0257:                                    .getString("unknown_entity"),
0258:                                    new Object[] { entity }));
0259:                        } catch (MissingResourceException e) {
0260:                            lexer.errout.println(e.toString());
0261:                        }
0262:                    } else if (code == UNESCAPED_AMPERSAND) {
0263:                        try {
0264:                            tidyPrint(lexer.errout, res
0265:                                    .getString("unescaped_ampersand"));
0266:                        } catch (MissingResourceException e) {
0267:                            lexer.errout.println(e.toString());
0268:                        }
0269:                    }
0270:
0271:                    tidyPrintln(lexer.errout);
0272:                }
0273:            }
0274:
0275:            public static void attrError(Lexer lexer, Node node, String attr,
0276:                    short code) {
0277:                lexer.warnings++;
0278:
0279:                /* keep quiet after 6 errors */
0280:                if (lexer.errors > 6)
0281:                    return;
0282:
0283:                if (lexer.configuration.ShowWarnings) {
0284:                    /* on end of file adjust reported position to end of input */
0285:                    if (code == UNEXPECTED_END_OF_FILE) {
0286:                        lexer.lines = lexer.in.curline;
0287:                        lexer.columns = lexer.in.curcol;
0288:                    }
0289:
0290:                    position(lexer);
0291:
0292:                    if (code == UNKNOWN_ATTRIBUTE) {
0293:                        try {
0294:                            tidyPrint(lexer.errout, MessageFormat.format(res
0295:                                    .getString("unknown_attribute"),
0296:                                    new Object[] { attr }));
0297:                        } catch (MissingResourceException e) {
0298:                            lexer.errout.println(e.toString());
0299:                        }
0300:                    } else if (code == MISSING_ATTRIBUTE) {
0301:                        try {
0302:                            tidyPrint(lexer.errout, res.getString("warning"));
0303:                            tag(lexer, node);
0304:                            tidyPrint(lexer.errout, MessageFormat.format(res
0305:                                    .getString("missing_attribute"),
0306:                                    new Object[] { attr }));
0307:                        } catch (MissingResourceException e) {
0308:                            lexer.errout.println(e.toString());
0309:                        }
0310:                    } else if (code == MISSING_ATTR_VALUE) {
0311:                        try {
0312:                            tidyPrint(lexer.errout, res.getString("warning"));
0313:                            tag(lexer, node);
0314:                            tidyPrint(lexer.errout, MessageFormat.format(res
0315:                                    .getString("missing_attr_value"),
0316:                                    new Object[] { attr }));
0317:                        } catch (MissingResourceException e) {
0318:                            lexer.errout.println(e.toString());
0319:                        }
0320:                    } else if (code == MISSING_IMAGEMAP) {
0321:                        try {
0322:                            tidyPrint(lexer.errout, res.getString("warning"));
0323:                            tag(lexer, node);
0324:                            tidyPrint(lexer.errout, res
0325:                                    .getString("missing_imagemap"));
0326:                        } catch (MissingResourceException e) {
0327:                            lexer.errout.println(e.toString());
0328:                        }
0329:                        lexer.badAccess |= MISSING_IMAGE_MAP;
0330:                    } else if (code == BAD_ATTRIBUTE_VALUE) {
0331:                        try {
0332:                            tidyPrint(lexer.errout, res.getString("warning"));
0333:                            tag(lexer, node);
0334:                            tidyPrint(lexer.errout, MessageFormat.format(res
0335:                                    .getString("bad_attribute_value"),
0336:                                    new Object[] { attr }));
0337:                        } catch (MissingResourceException e) {
0338:                            lexer.errout.println(e.toString());
0339:                        }
0340:                    } else if (code == XML_ATTRIBUTE_VALUE) {
0341:                        try {
0342:                            tidyPrint(lexer.errout, res.getString("warning"));
0343:                            tag(lexer, node);
0344:                            tidyPrint(lexer.errout, MessageFormat.format(res
0345:                                    .getString("xml_attribute_value"),
0346:                                    new Object[] { attr }));
0347:                        } catch (MissingResourceException e) {
0348:                            lexer.errout.println(e.toString());
0349:                        }
0350:                    } else if (code == UNEXPECTED_GT) {
0351:                        try {
0352:                            tidyPrint(lexer.errout, res.getString("error"));
0353:                            tag(lexer, node);
0354:                            tidyPrint(lexer.errout, res
0355:                                    .getString("unexpected_gt"));
0356:                        } catch (MissingResourceException e) {
0357:                            lexer.errout.println(e.toString());
0358:                        }
0359:                        lexer.errors++;
0360:                        ;
0361:                    } else if (code == UNEXPECTED_QUOTEMARK) {
0362:                        try {
0363:                            tidyPrint(lexer.errout, res.getString("warning"));
0364:                            tag(lexer, node);
0365:                            tidyPrint(lexer.errout, res
0366:                                    .getString("unexpected_quotemark"));
0367:                        } catch (MissingResourceException e) {
0368:                            lexer.errout.println(e.toString());
0369:                        }
0370:                    } else if (code == REPEATED_ATTRIBUTE) {
0371:                        try {
0372:                            tidyPrint(lexer.errout, res.getString("warning"));
0373:                            tag(lexer, node);
0374:                            tidyPrint(lexer.errout, res
0375:                                    .getString("repeated_attribute"));
0376:                        } catch (MissingResourceException e) {
0377:                            lexer.errout.println(e.toString());
0378:                        }
0379:                    } else if (code == PROPRIETARY_ATTR_VALUE) {
0380:                        try {
0381:                            tidyPrint(lexer.errout, res.getString("warning"));
0382:                            tag(lexer, node);
0383:                            tidyPrint(lexer.errout, MessageFormat.format(res
0384:                                    .getString("proprietary_attr_value"),
0385:                                    new Object[] { attr }));
0386:                        } catch (MissingResourceException e) {
0387:                            lexer.errout.println(e.toString());
0388:                        }
0389:                    } else if (code == UNEXPECTED_END_OF_FILE) {
0390:                        try {
0391:                            tidyPrint(lexer.errout, res
0392:                                    .getString("unexpected_end_of_file"));
0393:                        } catch (MissingResourceException e) {
0394:                            lexer.errout.println(e.toString());
0395:                        }
0396:                    } else if (code == ID_NAME_MISMATCH) {
0397:                        try {
0398:                            tidyPrint(lexer.errout, res.getString("warning"));
0399:                            tag(lexer, node);
0400:                            tidyPrint(lexer.errout, res
0401:                                    .getString("id_name_mismatch"));
0402:                        } catch (MissingResourceException e) {
0403:                            lexer.errout.println(e.toString());
0404:                        }
0405:                    }
0406:
0407:                    tidyPrintln(lexer.errout);
0408:                } else if (code == UNEXPECTED_GT) {
0409:                    position(lexer);
0410:                    try {
0411:                        tidyPrint(lexer.errout, res.getString("error"));
0412:                        tag(lexer, node);
0413:                        tidyPrint(lexer.errout, res.getString("unexpected_gt"));
0414:                    } catch (MissingResourceException e) {
0415:                        lexer.errout.println(e.toString());
0416:                    }
0417:                    tidyPrintln(lexer.errout);
0418:                    lexer.errors++;
0419:                    ;
0420:                }
0421:            }
0422:
0423:            public static void warning(Lexer lexer, Node element, Node node,
0424:                    short code) {
0425:
0426:                TagTable tt = lexer.configuration.tt;
0427:
0428:                lexer.warnings++;
0429:
0430:                /* keep quiet after 6 errors */
0431:                if (lexer.errors > 6)
0432:                    return;
0433:
0434:                if (lexer.configuration.ShowWarnings) {
0435:                    /* on end of file adjust reported position to end of input */
0436:                    if (code == UNEXPECTED_END_OF_FILE) {
0437:                        lexer.lines = lexer.in.curline;
0438:                        lexer.columns = lexer.in.curcol;
0439:                    }
0440:
0441:                    position(lexer);
0442:
0443:                    if (code == MISSING_ENDTAG_FOR) {
0444:                        try {
0445:                            tidyPrint(lexer.errout, MessageFormat.format(res
0446:                                    .getString("missing_endtag_for"),
0447:                                    new Object[] { element.element }));
0448:                        } catch (MissingResourceException e) {
0449:                            lexer.errout.println(e.toString());
0450:                        }
0451:                    } else if (code == MISSING_ENDTAG_BEFORE) {
0452:                        try {
0453:                            tidyPrint(lexer.errout, MessageFormat.format(res
0454:                                    .getString("missing_endtag_before"),
0455:                                    new Object[] { element.element }));
0456:                        } catch (MissingResourceException e) {
0457:                            lexer.errout.println(e.toString());
0458:                        }
0459:                        tag(lexer, node);
0460:                    } else if (code == DISCARDING_UNEXPECTED) {
0461:                        try {
0462:                            tidyPrint(lexer.errout, res
0463:                                    .getString("discarding_unexpected"));
0464:                        } catch (MissingResourceException e) {
0465:                            lexer.errout.println(e.toString());
0466:                        }
0467:                        tag(lexer, node);
0468:                    } else if (code == NESTED_EMPHASIS) {
0469:                        try {
0470:                            tidyPrint(lexer.errout, res
0471:                                    .getString("nested_emphasis"));
0472:                        } catch (MissingResourceException e) {
0473:                            lexer.errout.println(e.toString());
0474:                        }
0475:                        tag(lexer, node);
0476:                    } else if (code == COERCE_TO_ENDTAG) {
0477:                        try {
0478:                            tidyPrint(lexer.errout, MessageFormat.format(res
0479:                                    .getString("coerce_to_endtag"),
0480:                                    new Object[] { element.element }));
0481:                        } catch (MissingResourceException e) {
0482:                            lexer.errout.println(e.toString());
0483:                        }
0484:                    } else if (code == NON_MATCHING_ENDTAG) {
0485:                        try {
0486:                            tidyPrint(lexer.errout, res
0487:                                    .getString("non_matching_endtag_1"));
0488:                        } catch (MissingResourceException e) {
0489:                            lexer.errout.println(e.toString());
0490:                        }
0491:                        tag(lexer, node);
0492:                        try {
0493:                            tidyPrint(lexer.errout, MessageFormat.format(res
0494:                                    .getString("non_matching_endtag_2"),
0495:                                    new Object[] { element.element }));
0496:                        } catch (MissingResourceException e) {
0497:                            lexer.errout.println(e.toString());
0498:                        }
0499:                    } else if (code == TAG_NOT_ALLOWED_IN) {
0500:                        try {
0501:                            tidyPrint(lexer.errout, res.getString("warning"));
0502:                        } catch (MissingResourceException e) {
0503:                            lexer.errout.println(e.toString());
0504:                        }
0505:                        tag(lexer, node);
0506:                        try {
0507:                            tidyPrint(lexer.errout, MessageFormat.format(res
0508:                                    .getString("tag_not_allowed_in"),
0509:                                    new Object[] { element.element }));
0510:                        } catch (MissingResourceException e) {
0511:                            lexer.errout.println(e.toString());
0512:                        }
0513:                    } else if (code == DOCTYPE_AFTER_TAGS) {
0514:                        try {
0515:                            tidyPrint(lexer.errout, res
0516:                                    .getString("doctype_after_tags"));
0517:                        } catch (MissingResourceException e) {
0518:                            lexer.errout.println(e.toString());
0519:                        }
0520:                    } else if (code == MISSING_STARTTAG) {
0521:                        try {
0522:                            tidyPrint(lexer.errout, MessageFormat.format(res
0523:                                    .getString("missing_starttag"),
0524:                                    new Object[] { node.element }));
0525:                        } catch (MissingResourceException e) {
0526:                            lexer.errout.println(e.toString());
0527:                        }
0528:                    } else if (code == UNEXPECTED_ENDTAG) {
0529:                        try {
0530:                            tidyPrint(lexer.errout, MessageFormat.format(res
0531:                                    .getString("unexpected_endtag"),
0532:                                    new Object[] { node.element }));
0533:                            if (element != null)
0534:                                tidyPrint(
0535:                                        lexer.errout,
0536:                                        MessageFormat
0537:                                                .format(
0538:                                                        res
0539:                                                                .getString("unexpected_endtag_suffix"),
0540:                                                        new Object[] { element.element }));
0541:                        } catch (MissingResourceException e) {
0542:                            lexer.errout.println(e.toString());
0543:                        }
0544:                    } else if (code == TOO_MANY_ELEMENTS) {
0545:                        try {
0546:                            tidyPrint(lexer.errout, MessageFormat.format(res
0547:                                    .getString("too_many_elements"),
0548:                                    new Object[] { node.element }));
0549:                            if (element != null)
0550:                                tidyPrint(
0551:                                        lexer.errout,
0552:                                        MessageFormat
0553:                                                .format(
0554:                                                        res
0555:                                                                .getString("too_many_elements_suffix"),
0556:                                                        new Object[] { element.element }));
0557:                        } catch (MissingResourceException e) {
0558:                            lexer.errout.println(e.toString());
0559:                        }
0560:                    } else if (code == USING_BR_INPLACE_OF) {
0561:                        try {
0562:                            tidyPrint(lexer.errout, res
0563:                                    .getString("using_br_inplace_of"));
0564:                        } catch (MissingResourceException e) {
0565:                            lexer.errout.println(e.toString());
0566:                        }
0567:                        tag(lexer, node);
0568:                    } else if (code == INSERTING_TAG) {
0569:                        try {
0570:                            tidyPrint(lexer.errout, MessageFormat.format(res
0571:                                    .getString("inserting_tag"),
0572:                                    new Object[] { node.element }));
0573:                        } catch (MissingResourceException e) {
0574:                            lexer.errout.println(e.toString());
0575:                        }
0576:                    } else if (code == CANT_BE_NESTED) {
0577:                        try {
0578:                            tidyPrint(lexer.errout, res.getString("warning"));
0579:                        } catch (MissingResourceException e) {
0580:                            lexer.errout.println(e.toString());
0581:                        }
0582:                        tag(lexer, node);
0583:                        try {
0584:                            tidyPrint(lexer.errout, res
0585:                                    .getString("cant_be_nested"));
0586:                        } catch (MissingResourceException e) {
0587:                            lexer.errout.println(e.toString());
0588:                        }
0589:                    } else if (code == PROPRIETARY_ELEMENT) {
0590:                        try {
0591:                            tidyPrint(lexer.errout, res.getString("warning"));
0592:                        } catch (MissingResourceException e) {
0593:                            lexer.errout.println(e.toString());
0594:                        }
0595:                        tag(lexer, node);
0596:                        try {
0597:                            tidyPrint(lexer.errout, res
0598:                                    .getString("proprietary_element"));
0599:                        } catch (MissingResourceException e) {
0600:                            lexer.errout.println(e.toString());
0601:                        }
0602:
0603:                        if (node.tag == tt.tagLayer)
0604:                            lexer.badLayout |= USING_LAYER;
0605:                        else if (node.tag == tt.tagSpacer)
0606:                            lexer.badLayout |= USING_SPACER;
0607:                        else if (node.tag == tt.tagNobr)
0608:                            lexer.badLayout |= USING_NOBR;
0609:                    } else if (code == OBSOLETE_ELEMENT) {
0610:                        try {
0611:                            if (element.tag != null
0612:                                    && (element.tag.model & Dict.CM_OBSOLETE) != 0)
0613:                                tidyPrint(lexer.errout, res
0614:                                        .getString("obsolete_element"));
0615:                            else
0616:                                tidyPrint(lexer.errout, res
0617:                                        .getString("replacing_element"));
0618:
0619:                        } catch (MissingResourceException e) {
0620:                            lexer.errout.println(e.toString());
0621:                        }
0622:                        tag(lexer, element);
0623:                        try {
0624:                            tidyPrint(lexer.errout, res.getString("by"));
0625:                        } catch (MissingResourceException e) {
0626:                            lexer.errout.println(e.toString());
0627:                        }
0628:                        tag(lexer, node);
0629:                    } else if (code == TRIM_EMPTY_ELEMENT) {
0630:                        try {
0631:                            tidyPrint(lexer.errout, res
0632:                                    .getString("trim_empty_element"));
0633:                        } catch (MissingResourceException e) {
0634:                            lexer.errout.println(e.toString());
0635:                        }
0636:                        tag(lexer, element);
0637:                    } else if (code == MISSING_TITLE_ELEMENT) {
0638:                        try {
0639:                            tidyPrint(lexer.errout, res
0640:                                    .getString("missing_title_element"));
0641:                        } catch (MissingResourceException e) {
0642:                            lexer.errout.println(e.toString());
0643:                        }
0644:                    } else if (code == ILLEGAL_NESTING) {
0645:                        try {
0646:                            tidyPrint(lexer.errout, res.getString("warning"));
0647:                        } catch (MissingResourceException e) {
0648:                            lexer.errout.println(e.toString());
0649:                        }
0650:                        tag(lexer, element);
0651:                        try {
0652:                            tidyPrint(lexer.errout, res
0653:                                    .getString("illegal_nesting"));
0654:                        } catch (MissingResourceException e) {
0655:                            lexer.errout.println(e.toString());
0656:                        }
0657:                    } else if (code == NOFRAMES_CONTENT) {
0658:                        try {
0659:                            tidyPrint(lexer.errout, res.getString("warning"));
0660:                        } catch (MissingResourceException e) {
0661:                            lexer.errout.println(e.toString());
0662:                        }
0663:                        tag(lexer, node);
0664:                        try {
0665:                            tidyPrint(lexer.errout, res
0666:                                    .getString("noframes_content"));
0667:                        } catch (MissingResourceException e) {
0668:                            lexer.errout.println(e.toString());
0669:                        }
0670:                    } else if (code == INCONSISTENT_VERSION) {
0671:                        try {
0672:                            tidyPrint(lexer.errout, res
0673:                                    .getString("inconsistent_version"));
0674:                        } catch (MissingResourceException e) {
0675:                            lexer.errout.println(e.toString());
0676:                        }
0677:                    } else if (code == MALFORMED_DOCTYPE) {
0678:                        try {
0679:                            tidyPrint(lexer.errout, res
0680:                                    .getString("malformed_doctype"));
0681:                        } catch (MissingResourceException e) {
0682:                            lexer.errout.println(e.toString());
0683:                        }
0684:                    } else if (code == CONTENT_AFTER_BODY) {
0685:                        try {
0686:                            tidyPrint(lexer.errout, res
0687:                                    .getString("content_after_body"));
0688:                        } catch (MissingResourceException e) {
0689:                            lexer.errout.println(e.toString());
0690:                        }
0691:                    } else if (code == MALFORMED_COMMENT) {
0692:                        try {
0693:                            tidyPrint(lexer.errout, res
0694:                                    .getString("malformed_comment"));
0695:                        } catch (MissingResourceException e) {
0696:                            lexer.errout.println(e.toString());
0697:                        }
0698:                    } else if (code == BAD_COMMENT_CHARS) {
0699:                        try {
0700:                            tidyPrint(lexer.errout, res
0701:                                    .getString("bad_comment_chars"));
0702:                        } catch (MissingResourceException e) {
0703:                            lexer.errout.println(e.toString());
0704:                        }
0705:                    } else if (code == BAD_XML_COMMENT) {
0706:                        try {
0707:                            tidyPrint(lexer.errout, res
0708:                                    .getString("bad_xml_comment"));
0709:                        } catch (MissingResourceException e) {
0710:                            lexer.errout.println(e.toString());
0711:                        }
0712:                    } else if (code == BAD_CDATA_CONTENT) {
0713:                        try {
0714:                            tidyPrint(lexer.errout, res
0715:                                    .getString("bad_cdata_content"));
0716:                        } catch (MissingResourceException e) {
0717:                            lexer.errout.println(e.toString());
0718:                        }
0719:                    } else if (code == INCONSISTENT_NAMESPACE) {
0720:                        try {
0721:                            tidyPrint(lexer.errout, res
0722:                                    .getString("inconsistent_namespace"));
0723:                        } catch (MissingResourceException e) {
0724:                            lexer.errout.println(e.toString());
0725:                        }
0726:                    } else if (code == DTYPE_NOT_UPPER_CASE) {
0727:                        try {
0728:                            tidyPrint(lexer.errout, res
0729:                                    .getString("dtype_not_upper_case"));
0730:                        } catch (MissingResourceException e) {
0731:                            lexer.errout.println(e.toString());
0732:                        }
0733:                    } else if (code == UNEXPECTED_END_OF_FILE) {
0734:                        try {
0735:                            tidyPrint(lexer.errout, res
0736:                                    .getString("unexpected_end_of_file"));
0737:                        } catch (MissingResourceException e) {
0738:                            lexer.errout.println(e.toString());
0739:                        }
0740:                        tag(lexer, element);
0741:                    }
0742:
0743:                    tidyPrintln(lexer.errout);
0744:                }
0745:            }
0746:
0747:            public static void error(Lexer lexer, Node element, Node node,
0748:                    short code) {
0749:                lexer.warnings++;
0750:
0751:                /* keep quiet after 6 errors */
0752:                if (lexer.errors > 6)
0753:                    return;
0754:
0755:                lexer.errors++;
0756:
0757:                position(lexer);
0758:
0759:                if (code == SUSPECTED_MISSING_QUOTE) {
0760:                    try {
0761:                        tidyPrint(lexer.errout, res
0762:                                .getString("suspected_missing_quote"));
0763:                    } catch (MissingResourceException e) {
0764:                        lexer.errout.println(e.toString());
0765:                    }
0766:                } else if (code == DUPLICATE_FRAMESET) {
0767:                    try {
0768:                        tidyPrint(lexer.errout, res
0769:                                .getString("duplicate_frameset"));
0770:                    } catch (MissingResourceException e) {
0771:                        lexer.errout.println(e.toString());
0772:                    }
0773:                } else if (code == UNKNOWN_ELEMENT) {
0774:                    try {
0775:                        tidyPrint(lexer.errout, res.getString("error"));
0776:                    } catch (MissingResourceException e) {
0777:                        lexer.errout.println(e.toString());
0778:                    }
0779:                    tag(lexer, node);
0780:                    try {
0781:                        tidyPrint(lexer.errout, res
0782:                                .getString("unknown_element"));
0783:                    } catch (MissingResourceException e) {
0784:                        lexer.errout.println(e.toString());
0785:                    }
0786:                } else if (code == UNEXPECTED_ENDTAG) {
0787:                    try {
0788:                        tidyPrint(lexer.errout, MessageFormat.format(res
0789:                                .getString("unexpected_endtag"),
0790:                                new Object[] { node.element }));
0791:                        if (element != null)
0792:                            tidyPrint(lexer.errout, MessageFormat.format(res
0793:                                    .getString("unexpected_endtag_suffix"),
0794:                                    new Object[] { element.element }));
0795:                    } catch (MissingResourceException e) {
0796:                        lexer.errout.println(e.toString());
0797:                    }
0798:                }
0799:
0800:                tidyPrintln(lexer.errout);
0801:            }
0802:
0803:            public static void errorSummary(Lexer lexer) {
0804:                /* adjust badAccess to that its null if frames are ok */
0805:                if ((lexer.badAccess & (USING_FRAMES | USING_NOFRAMES)) != 0) {
0806:                    if (!(((lexer.badAccess & USING_FRAMES) != 0) && ((lexer.badAccess & USING_NOFRAMES) == 0)))
0807:                        lexer.badAccess &= ~(USING_FRAMES | USING_NOFRAMES);
0808:                }
0809:
0810:                if (lexer.badChars != 0) {
0811:                    if ((lexer.badChars & WINDOWS_CHARS) != 0) {
0812:                        try {
0813:                            tidyPrint(lexer.errout, res
0814:                                    .getString("badchars_summary"));
0815:                        } catch (MissingResourceException e) {
0816:                            lexer.errout.println(e.toString());
0817:                        }
0818:                    }
0819:                }
0820:
0821:                if (lexer.badForm != 0) {
0822:                    try {
0823:                        tidyPrint(lexer.errout, res
0824:                                .getString("badform_summary"));
0825:                    } catch (MissingResourceException e) {
0826:                        lexer.errout.println(e.toString());
0827:                    }
0828:                }
0829:
0830:                if (lexer.badAccess != 0) {
0831:                    if ((lexer.badAccess & MISSING_SUMMARY) != 0) {
0832:                        try {
0833:                            tidyPrint(lexer.errout, res
0834:                                    .getString("badaccess_missing_summary"));
0835:                        } catch (MissingResourceException e) {
0836:                            lexer.errout.println(e.toString());
0837:                        }
0838:                    }
0839:
0840:                    if ((lexer.badAccess & MISSING_IMAGE_ALT) != 0) {
0841:                        try {
0842:                            tidyPrint(lexer.errout, res
0843:                                    .getString("badaccess_missing_image_alt"));
0844:                        } catch (MissingResourceException e) {
0845:                            lexer.errout.println(e.toString());
0846:                        }
0847:                    }
0848:
0849:                    if ((lexer.badAccess & MISSING_IMAGE_MAP) != 0) {
0850:                        try {
0851:                            tidyPrint(lexer.errout, res
0852:                                    .getString("badaccess_missing_image_map"));
0853:                        } catch (MissingResourceException e) {
0854:                            lexer.errout.println(e.toString());
0855:                        }
0856:                    }
0857:
0858:                    if ((lexer.badAccess & MISSING_LINK_ALT) != 0) {
0859:                        try {
0860:                            tidyPrint(lexer.errout, res
0861:                                    .getString("badaccess_missing_link_alt"));
0862:                        } catch (MissingResourceException e) {
0863:                            lexer.errout.println(e.toString());
0864:                        }
0865:                    }
0866:
0867:                    if (((lexer.badAccess & USING_FRAMES) != 0)
0868:                            && ((lexer.badAccess & USING_NOFRAMES) == 0)) {
0869:                        try {
0870:                            tidyPrint(lexer.errout, res
0871:                                    .getString("badaccess_frames"));
0872:                        } catch (MissingResourceException e) {
0873:                            lexer.errout.println(e.toString());
0874:                        }
0875:                    }
0876:
0877:                    try {
0878:                        tidyPrint(lexer.errout, MessageFormat.format(res
0879:                                .getString("badaccess_summary"),
0880:                                new Object[] { ACCESS_URL }));
0881:                    } catch (MissingResourceException e) {
0882:                        lexer.errout.println(e.toString());
0883:                    }
0884:                }
0885:
0886:                if (lexer.badLayout != 0) {
0887:                    if ((lexer.badLayout & USING_LAYER) != 0) {
0888:                        try {
0889:                            tidyPrint(lexer.errout, res
0890:                                    .getString("badlayout_using_layer"));
0891:                        } catch (MissingResourceException e) {
0892:                            lexer.errout.println(e.toString());
0893:                        }
0894:                    }
0895:
0896:                    if ((lexer.badLayout & USING_SPACER) != 0) {
0897:                        try {
0898:                            tidyPrint(lexer.errout, res
0899:                                    .getString("badlayout_using_spacer"));
0900:                        } catch (MissingResourceException e) {
0901:                            lexer.errout.println(e.toString());
0902:                        }
0903:                    }
0904:
0905:                    if ((lexer.badLayout & USING_FONT) != 0) {
0906:                        try {
0907:                            tidyPrint(lexer.errout, res
0908:                                    .getString("badlayout_using_font"));
0909:                        } catch (MissingResourceException e) {
0910:                            lexer.errout.println(e.toString());
0911:                        }
0912:                    }
0913:
0914:                    if ((lexer.badLayout & USING_NOBR) != 0) {
0915:                        try {
0916:                            tidyPrint(lexer.errout, res
0917:                                    .getString("badlayout_using_nobr"));
0918:                        } catch (MissingResourceException e) {
0919:                            lexer.errout.println(e.toString());
0920:                        }
0921:                    }
0922:
0923:                    if ((lexer.badLayout & USING_BODY) != 0) {
0924:                        try {
0925:                            tidyPrint(lexer.errout, res
0926:                                    .getString("badlayout_using_body"));
0927:                        } catch (MissingResourceException e) {
0928:                            lexer.errout.println(e.toString());
0929:                        }
0930:                    }
0931:                }
0932:            }
0933:
0934:            public static void unknownOption(PrintWriter errout, char c) {
0935:                try {
0936:                    tidyPrintln(errout, MessageFormat.format(res
0937:                            .getString("unrecognized_option"),
0938:                            new Object[] { new String(new char[] { c }) }));
0939:                } catch (MissingResourceException e) {
0940:                    errout.println(e.toString());
0941:                }
0942:            }
0943:
0944:            public static void unknownFile(PrintWriter errout, String program,
0945:                    String file) {
0946:                try {
0947:                    tidyPrintln(errout, MessageFormat.format(res
0948:                            .getString("unknown_file"), new Object[] { program,
0949:                            file }));
0950:                } catch (MissingResourceException e) {
0951:                    errout.println(e.toString());
0952:                }
0953:            }
0954:
0955:            public static void needsAuthorIntervention(PrintWriter errout) {
0956:                try {
0957:                    tidyPrintln(errout, res
0958:                            .getString("needs_author_intervention"));
0959:                } catch (MissingResourceException e) {
0960:                    errout.println(e.toString());
0961:                }
0962:            }
0963:
0964:            public static void missingBody(PrintWriter errout) {
0965:                try {
0966:                    tidyPrintln(errout, res.getString("missing_body"));
0967:                } catch (MissingResourceException e) {
0968:                    errout.println(e.toString());
0969:                }
0970:            }
0971:
0972:            public static void reportNumberOfSlides(PrintWriter errout,
0973:                    int count) {
0974:                try {
0975:                    tidyPrintln(errout, MessageFormat.format(res
0976:                            .getString("slides_found"),
0977:                            new Object[] { new Integer(count) }));
0978:                } catch (MissingResourceException e) {
0979:                    errout.println(e.toString());
0980:                }
0981:            }
0982:
0983:            public static void generalInfo(PrintWriter errout) {
0984:                try {
0985:                    tidyPrintln(errout, res.getString("general_info"));
0986:                } catch (MissingResourceException e) {
0987:                    errout.println(e.toString());
0988:                }
0989:            }
0990:
0991:            public static void helloMessage(PrintWriter errout, String date,
0992:                    String filename) {
0993:                currentFile = filename; /* for use with Gnu Emacs */
0994:
0995:                try {
0996:                    tidyPrintln(errout, MessageFormat.format(res
0997:                            .getString("hello_message"), new Object[] { date,
0998:                            filename }));
0999:                } catch (MissingResourceException e) {
1000:                    errout.println(e.toString());
1001:                }
1002:            }
1003:
1004:            public static void reportVersion(PrintWriter errout, Lexer lexer,
1005:                    String filename, Node doctype) {
1006:                int i, c;
1007:                int state = 0;
1008:                String vers = lexer.HTMLVersionName();
1009:                MutableInteger cc = new MutableInteger();
1010:
1011:                try {
1012:                    if (doctype != null) {
1013:                        tidyPrint(errout, MessageFormat.format(res
1014:                                .getString("doctype_given"),
1015:                                new Object[] { filename }));
1016:
1017:                        for (i = doctype.start; i < doctype.end; ++i) {
1018:                            c = (int) doctype.textarray[i];
1019:
1020:                            /* look for UTF-8 multibyte character */
1021:                            if (c < 0) {
1022:                                i += PPrint.getUTF8(doctype.textarray, i, cc);
1023:                                c = cc.value;
1024:                            }
1025:
1026:                            if (c == (char) '"')
1027:                                ++state;
1028:                            else if (state == 1)
1029:                                errout.print((char) c);
1030:                        }
1031:
1032:                        errout.print('"');
1033:                    }
1034:
1035:                    tidyPrintln(errout, MessageFormat.format(res
1036:                            .getString("report_version"), new Object[] {
1037:                            filename,
1038:                            (vers != null ? vers : "HTML proprietary") }));
1039:                } catch (MissingResourceException e) {
1040:                    errout.println(e.toString());
1041:                }
1042:            }
1043:
1044:            public static void reportNumWarnings(PrintWriter errout, Lexer lexer) {
1045:                if (lexer.warnings > 0) {
1046:                    try {
1047:                        tidyPrintln(errout, MessageFormat.format(res
1048:                                .getString("num_warnings"),
1049:                                new Object[] { new Integer(lexer.warnings) }));
1050:                    } catch (MissingResourceException e) {
1051:                        errout.println(e.toString());
1052:                    }
1053:                } else {
1054:                    try {
1055:                        tidyPrintln(errout, res.getString("no_warnings"));
1056:                    } catch (MissingResourceException e) {
1057:                        errout.println(e.toString());
1058:                    }
1059:                }
1060:            }
1061:
1062:            public static void helpText(PrintWriter out, String prog) {
1063:                try {
1064:                    tidyPrintln(out, MessageFormat.format(res
1065:                            .getString("help_text"), new Object[] { prog,
1066:                            RELEASE_DATE }));
1067:                } catch (MissingResourceException e) {
1068:                    out.println(e.toString());
1069:                }
1070:            }
1071:
1072:            public static void badTree(PrintWriter errout) {
1073:                try {
1074:                    tidyPrintln(errout, res.getString("bad_tree"));
1075:                } catch (MissingResourceException e) {
1076:                    errout.println(e.toString());
1077:                }
1078:            }
1079:
1080:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.