Source Code Cross Referenced for DOMErrorHandlerWrapper.java in  » XML » xerces-2_9_1 » org » apache » xerces » util » 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 » XML » xerces 2_9_1 » org.apache.xerces.util 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Licensed to the Apache Software Foundation (ASF) under one or more
003:         * contributor license agreements.  See the NOTICE file distributed with
004:         * this work for additional information regarding copyright ownership.
005:         * The ASF licenses this file to You under the Apache License, Version 2.0
006:         * (the "License"); you may not use this file except in compliance with
007:         * the License.  You may obtain a copy of the License at
008:         * 
009:         *      http://www.apache.org/licenses/LICENSE-2.0
010:         * 
011:         * Unless required by applicable law or agreed to in writing, software
012:         * distributed under the License is distributed on an "AS IS" BASIS,
013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         * See the License for the specific language governing permissions and
015:         * limitations under the License.
016:         */
017:
018:        package org.apache.xerces.util;
019:
020:        import org.apache.xerces.xni.XNIException;
021:        import org.apache.xerces.xni.parser.XMLErrorHandler;
022:        import org.apache.xerces.xni.parser.XMLParseException;
023:
024:        import org.w3c.dom.Node;
025:        import org.w3c.dom.DOMError;
026:        import org.w3c.dom.DOMLocator;
027:        import org.w3c.dom.DOMErrorHandler;
028:        import org.apache.xerces.dom.DOMErrorImpl;
029:        import org.apache.xerces.dom.DOMLocatorImpl;
030:        import org.apache.xerces.impl.msg.XMLMessageFormatter;
031:
032:        import java.io.PrintWriter;
033:        import java.util.Hashtable;
034:
035:        /**
036:         * This class handles DOM errors .
037:         *
038:         * @see DOMErrorHandler
039:         *
040:         * @author Gopal Sharma, SUN Microsystems Inc.
041:         * @version $Id: DOMErrorHandlerWrapper.java 447241 2006-09-18 05:12:57Z mrglavas $
042:         */
043:
044:        // REVISIT: current implementations wraps error several times:
045:        //          XMLErrorReport.reportError creates XMLParserException (by wrapping all info)
046:        //          and goes via switch to send errors.
047:        //          DOMErrorHandlerWrapper catches calls, copies info from XMLParserException and
048:        //          sends one call back to the application
049:        //          I think we can avoid this indirection if we modify XMLErrorReporter. --el
050:        public class DOMErrorHandlerWrapper implements  XMLErrorHandler,
051:                DOMErrorHandler {
052:
053:            // It keeps the reference of DOMErrorHandler of application
054:            protected DOMErrorHandler fDomErrorHandler;
055:
056:            // Error Status
057:            boolean eStatus = true;
058:
059:            // Print writer
060:            protected PrintWriter fOut;
061:
062:            // some components may set error node
063:            // @see DOMNormalizer.
064:            public Node fCurrentNode;
065:
066:            /** Error code for comparisons. **/
067:            protected final XMLErrorCode fErrorCode = new XMLErrorCode(null,
068:                    null);
069:
070:            protected final DOMErrorImpl fDOMError = new DOMErrorImpl();
071:
072:            //
073:            // Constructors
074:            //
075:
076:            // Default constructor /
077:
078:            public DOMErrorHandlerWrapper() {
079:                fOut = new PrintWriter(System.err);
080:            }
081:
082:            public DOMErrorHandlerWrapper(DOMErrorHandler domErrorHandler) {
083:                fDomErrorHandler = domErrorHandler;
084:            } // DOMErrorHandlerWrapper(DOMErrorHandler domErrorHandler)
085:
086:            //
087:            // Public methods
088:            //
089:
090:            /** Sets the DOM error handler. */
091:            public void setErrorHandler(DOMErrorHandler errorHandler) {
092:                fDomErrorHandler = errorHandler;
093:            } // setErrorHandler(ErrorHandler)
094:
095:            public DOMErrorHandler getErrorHandler() {
096:                return fDomErrorHandler;
097:            } //getErrorHandler()
098:
099:            //
100:            // XMLErrorHandler methods
101:            //
102:
103:            /**
104:             * Reports a warning. Warnings are non-fatal and can be safely ignored
105:             * by most applications.
106:             *
107:             * @param domain    The domain of the warning. The domain can be any
108:             *                  string but is suggested to be a valid URI. The
109:             *                  domain can be used to conveniently specify a web
110:             *                  site location of the relevent specification or
111:             *                  document pertaining to this warning.
112:             * @param key       The warning key. This key can be any string and
113:             *                  is implementation dependent.
114:             * @param exception Exception.
115:             *
116:             * @throws XNIException Thrown to signal that the parser should stop
117:             *                      parsing the document.
118:             */
119:
120:            public void warning(String domain, String key,
121:                    XMLParseException exception) throws XNIException {
122:                fDOMError.fSeverity = DOMError.SEVERITY_WARNING;
123:                fDOMError.fException = exception;
124:                // REVISIT: May need to lookup from DOMErrorTypeMap in the future.
125:                fDOMError.fType = key;
126:                fDOMError.fRelatedData = fDOMError.fMessage = exception
127:                        .getMessage();
128:                DOMLocatorImpl locator = fDOMError.fLocator;
129:                if (locator != null) {
130:                    locator.fColumnNumber = exception.getColumnNumber();
131:                    locator.fLineNumber = exception.getLineNumber();
132:                    locator.fUtf16Offset = exception.getCharacterOffset();
133:                    locator.fUri = exception.getExpandedSystemId();
134:                    locator.fRelatedNode = fCurrentNode;
135:                }
136:                if (fDomErrorHandler != null) {
137:                    fDomErrorHandler.handleError(fDOMError);
138:                }
139:            } // warning(String,String,XMLParseException)
140:
141:            /**
142:             * Reports an error. Errors are non-fatal and usually signify that the
143:             * document is invalid with respect to its grammar(s).
144:             *
145:             * @param domain    The domain of the error. The domain can be any
146:             *                  string but is suggested to be a valid URI. The
147:             *                  domain can be used to conveniently specify a web
148:             *                  site location of the relevent specification or
149:             *                  document pertaining to this error.
150:             * @param key       The error key. This key can be any string and
151:             *                  is implementation dependent.
152:             * @param exception Exception.
153:             *
154:             * @throws XNIException Thrown to signal that the parser should stop
155:             *                      parsing the document.
156:             */
157:            public void error(String domain, String key,
158:                    XMLParseException exception) throws XNIException {
159:                fDOMError.fSeverity = DOMError.SEVERITY_ERROR;
160:                fDOMError.fException = exception;
161:                // REVISIT: May need to lookup from DOMErrorTypeMap in the future.
162:                fDOMError.fType = key;
163:                fDOMError.fRelatedData = fDOMError.fMessage = exception
164:                        .getMessage();
165:                DOMLocatorImpl locator = fDOMError.fLocator;
166:                if (locator != null) {
167:                    locator.fColumnNumber = exception.getColumnNumber();
168:                    locator.fLineNumber = exception.getLineNumber();
169:                    locator.fUtf16Offset = exception.getCharacterOffset();
170:                    locator.fUri = exception.getExpandedSystemId();
171:                    locator.fRelatedNode = fCurrentNode;
172:                }
173:                if (fDomErrorHandler != null) {
174:                    fDomErrorHandler.handleError(fDOMError);
175:                }
176:            } // error(String,String,XMLParseException)
177:
178:            /**
179:             * Report a fatal error. Fatal errors usually occur when the document
180:             * is not well-formed and signifies that the parser cannot continue
181:             * normal operation.
182:             * <p>
183:             * <strong>Note:</strong> The error handler should <em>always</em>
184:             * throw an <code>XNIException</code> from this method. This exception
185:             * can either be the same exception that is passed as a parameter to
186:             * the method or a new XNI exception object. If the registered error
187:             * handler fails to throw an exception, the continuing operation of
188:             * the parser is undetermined.
189:             *
190:             * @param domain    The domain of the fatal error. The domain can be 
191:             *                  any string but is suggested to be a valid URI. The
192:             *                  domain can be used to conveniently specify a web
193:             *                  site location of the relevent specification or
194:             *                  document pertaining to this fatal error.
195:             * @param key       The fatal error key. This key can be any string 
196:             *                  and is implementation dependent.
197:             * @param exception Exception.
198:             *
199:             * @throws XNIException Thrown to signal that the parser should stop
200:             *                      parsing the document.
201:             */
202:            public void fatalError(String domain, String key,
203:                    XMLParseException exception) throws XNIException {
204:                fDOMError.fSeverity = DOMError.SEVERITY_FATAL_ERROR;
205:                fDOMError.fException = exception;
206:                fErrorCode.setValues(domain, key);
207:                String domErrorType = DOMErrorTypeMap
208:                        .getDOMErrorType(fErrorCode);
209:                fDOMError.fType = (domErrorType != null) ? domErrorType : key;
210:                fDOMError.fRelatedData = fDOMError.fMessage = exception
211:                        .getMessage();
212:                DOMLocatorImpl locator = fDOMError.fLocator;
213:                if (locator != null) {
214:                    locator.fColumnNumber = exception.getColumnNumber();
215:                    locator.fLineNumber = exception.getLineNumber();
216:                    locator.fUtf16Offset = exception.getCharacterOffset();
217:                    locator.fUri = exception.getExpandedSystemId();
218:                    locator.fRelatedNode = fCurrentNode;
219:                }
220:                if (fDomErrorHandler != null) {
221:                    fDomErrorHandler.handleError(fDOMError);
222:                }
223:            } // fatalError(String,String,XMLParseException)
224:
225:            public boolean handleError(DOMError error) {
226:                printError(error);
227:                return eStatus;
228:            }
229:
230:            /** Prints the error message. */
231:
232:            private void printError(DOMError error) {
233:                int severity = error.getSeverity();
234:                fOut.print("[");
235:                if (severity == DOMError.SEVERITY_WARNING) {
236:                    fOut.print("Warning");
237:                } else if (severity == DOMError.SEVERITY_ERROR) {
238:                    fOut.print("Error");
239:                } else {
240:                    fOut.print("FatalError");
241:                    eStatus = false; //REVISIT: Abort processing if fatal error, do we need to??
242:                }
243:                fOut.print("] ");
244:                DOMLocator locator = error.getLocation();
245:                if (locator != null) {
246:                    fOut.print(locator.getLineNumber());
247:                    fOut.print(":");
248:                    fOut.print(locator.getColumnNumber());
249:                    fOut.print(":");
250:                    fOut.print(locator.getByteOffset());
251:                    fOut.print(",");
252:                    fOut.print(locator.getUtf16Offset());
253:                    Node node = locator.getRelatedNode();
254:                    if (node != null) {
255:                        fOut.print("[");
256:                        fOut.print(node.getNodeName());
257:                        fOut.print("]");
258:                    }
259:                    String systemId = locator.getUri();
260:                    if (systemId != null) {
261:                        int index = systemId.lastIndexOf('/');
262:                        if (index != -1)
263:                            systemId = systemId.substring(index + 1);
264:                        fOut.print(": ");
265:                        fOut.print(systemId);
266:                    }
267:
268:                }
269:
270:                fOut.print(":");
271:                fOut.print(error.getMessage());
272:                fOut.println();
273:                fOut.flush();
274:
275:            } // printError(DOMError)
276:
277:            /**
278:             * A convenience class for converting between internal 
279:             * error codes and DOM error types.
280:             */
281:            private static class DOMErrorTypeMap {
282:
283:                /** Map for converting internal error codes to DOM error types. **/
284:                private static Hashtable fgDOMErrorTypeTable;
285:
286:                static {
287:                    // initialize error type table: internal error codes (represented by domain and key) need to be mapped to a DOM error type.
288:
289:                    // REVISIT: do well-formedness issues involving XML declaration <?xml ... ?> need to be added to hash table (no XML declaration node in DOM, but Document includes xmlEncoding, xmlStandalone, xmlVersion, etc.
290:
291:                    fgDOMErrorTypeTable = new Hashtable();
292:                    fgDOMErrorTypeTable.put(new XMLErrorCode(
293:                            XMLMessageFormatter.XML_DOMAIN,
294:                            "InvalidCharInCDSect"), "wf-invalid-character");
295:                    fgDOMErrorTypeTable.put(new XMLErrorCode(
296:                            XMLMessageFormatter.XML_DOMAIN,
297:                            "InvalidCharInContent"), "wf-invalid-character");
298:                    fgDOMErrorTypeTable.put(
299:                            new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN,
300:                                    "TwoColonsInQName"),
301:                            "wf-invalid-character-in-node-name");
302:                    fgDOMErrorTypeTable.put(new XMLErrorCode(
303:                            XMLMessageFormatter.XML_DOMAIN,
304:                            "ColonNotLegalWithNS"),
305:                            "wf-invalid-character-in-node-name");
306:                    fgDOMErrorTypeTable.put(new XMLErrorCode(
307:                            XMLMessageFormatter.XML_DOMAIN,
308:                            "InvalidCharInProlog"), "wf-invalid-character"); // e.g. in Processing Instruction
309:
310:                    // InvalidCharInXMLDecl omitted because XML declaration is not a DOM Node
311:                    fgDOMErrorTypeTable.put(new XMLErrorCode(
312:                            XMLMessageFormatter.XML_DOMAIN, "CDEndInContent"),
313:                            "wf-invalid-character");
314:                    fgDOMErrorTypeTable.put(new XMLErrorCode(
315:                            XMLMessageFormatter.XML_DOMAIN,
316:                            "CDSectUnterminated"), "wf-invalid-character");
317:                    fgDOMErrorTypeTable
318:                            .put(new XMLErrorCode(
319:                                    XMLMessageFormatter.XML_DOMAIN,
320:                                    "DoctypeNotAllowed"), "doctype-not-allowed");
321:                    fgDOMErrorTypeTable.put(new XMLErrorCode(
322:                            XMLMessageFormatter.XML_DOMAIN, "ETagRequired"),
323:                            "wf-invalid-character-in-node-name");
324:                    fgDOMErrorTypeTable.put(new XMLErrorCode(
325:                            XMLMessageFormatter.XML_DOMAIN,
326:                            "ElementUnterminated"),
327:                            "wf-invalid-character-in-node-name");
328:                    fgDOMErrorTypeTable.put(new XMLErrorCode(
329:                            XMLMessageFormatter.XML_DOMAIN,
330:                            "EqRequiredInAttribute"), "wf-invalid-character");
331:                    fgDOMErrorTypeTable.put(
332:                            new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN,
333:                                    "OpenQuoteExpected"),
334:                            "wf-invalid-character");
335:                    fgDOMErrorTypeTable.put(new XMLErrorCode(
336:                            XMLMessageFormatter.XML_DOMAIN,
337:                            "CloseQuoteExpected"), "wf-invalid-character");
338:                    fgDOMErrorTypeTable.put(
339:                            new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN,
340:                                    "ETagUnterminated"),
341:                            "wf-invalid-character-in-node-name");
342:                    fgDOMErrorTypeTable.put(new XMLErrorCode(
343:                            XMLMessageFormatter.XML_DOMAIN,
344:                            "MarkupNotRecognizedInContent"),
345:                            "wf-invalid-character");
346:                    fgDOMErrorTypeTable.put(new XMLErrorCode(
347:                            XMLMessageFormatter.XML_DOMAIN,
348:                            "DoctypeIllegalInContent"), "doctype-not-allowed");
349:                    fgDOMErrorTypeTable.put(new XMLErrorCode(
350:                            XMLMessageFormatter.XML_DOMAIN,
351:                            "InvalidCharInAttValue"), "wf-invalid-character");
352:                    fgDOMErrorTypeTable.put(new XMLErrorCode(
353:                            XMLMessageFormatter.XML_DOMAIN, "InvalidCharInPI"),
354:                            "wf-invalid-character");
355:                    fgDOMErrorTypeTable.put(new XMLErrorCode(
356:                            XMLMessageFormatter.XML_DOMAIN,
357:                            "InvalidCharInInternalSubset"),
358:                            "wf-invalid-character");
359:                    fgDOMErrorTypeTable.put(new XMLErrorCode(
360:                            XMLMessageFormatter.XML_DOMAIN,
361:                            "QuoteRequiredInAttValue"), "wf-invalid-character");
362:                    fgDOMErrorTypeTable.put(new XMLErrorCode(
363:                            XMLMessageFormatter.XML_DOMAIN,
364:                            "LessthanInAttValue"), "wf-invalid-character");
365:                    fgDOMErrorTypeTable.put(new XMLErrorCode(
366:                            XMLMessageFormatter.XML_DOMAIN,
367:                            "AttributeValueUnterminated"),
368:                            "wf-invalid-character");
369:                    fgDOMErrorTypeTable
370:                            .put(new XMLErrorCode(
371:                                    XMLMessageFormatter.XML_DOMAIN,
372:                                    "PITargetRequired"), "wf-invalid-character");
373:                    fgDOMErrorTypeTable.put(
374:                            new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN,
375:                                    "SpaceRequiredInPI"),
376:                            "wf-invalid-character");
377:                    fgDOMErrorTypeTable.put(new XMLErrorCode(
378:                            XMLMessageFormatter.XML_DOMAIN, "PIUnterminated"),
379:                            "wf-invalid-character");
380:                    fgDOMErrorTypeTable
381:                            .put(new XMLErrorCode(
382:                                    XMLMessageFormatter.XML_DOMAIN,
383:                                    "ReservedPITarget"), "wf-invalid-character");
384:                    fgDOMErrorTypeTable.put(new XMLErrorCode(
385:                            XMLMessageFormatter.XML_DOMAIN,
386:                            "PI_NOT_IN_ONE_ENTITY"), "wf-invalid-character");
387:                    fgDOMErrorTypeTable
388:                            .put(new XMLErrorCode(
389:                                    XMLMessageFormatter.XML_DOMAIN,
390:                                    "PINotInOneEntity"), "wf-invalid-character");
391:                    fgDOMErrorTypeTable.put(new XMLErrorCode(
392:                            XMLMessageFormatter.XML_DOMAIN,
393:                            "EncodingDeclInvalid"), "unsupported-encoding");
394:                    fgDOMErrorTypeTable.put(new XMLErrorCode(
395:                            XMLMessageFormatter.XML_DOMAIN,
396:                            "EncodingByteOrderUnsupported"),
397:                            "unsupported-encoding");
398:                    fgDOMErrorTypeTable.put(new XMLErrorCode(
399:                            XMLMessageFormatter.XML_DOMAIN,
400:                            "InvalidCharInEntityValue"),
401:                            "wf-invalid-character-in-node-name");
402:                    fgDOMErrorTypeTable.put(new XMLErrorCode(
403:                            XMLMessageFormatter.XML_DOMAIN,
404:                            "InvalidCharInExternalSubset"),
405:                            "wf-invalid-character");
406:                    fgDOMErrorTypeTable.put(new XMLErrorCode(
407:                            XMLMessageFormatter.XML_DOMAIN,
408:                            "InvalidCharInIgnoreSect"), "wf-invalid-character");
409:                    fgDOMErrorTypeTable.put(new XMLErrorCode(
410:                            XMLMessageFormatter.XML_DOMAIN,
411:                            "InvalidCharInPublicID"), "wf-invalid-character");
412:                    fgDOMErrorTypeTable.put(new XMLErrorCode(
413:                            XMLMessageFormatter.XML_DOMAIN,
414:                            "InvalidCharInSystemID"), "wf-invalid-character");
415:                    fgDOMErrorTypeTable
416:                            .put(new XMLErrorCode(
417:                                    XMLMessageFormatter.XML_DOMAIN,
418:                                    "SpaceRequiredAfterSYSTEM"),
419:                                    "wf-invalid-character");
420:                    fgDOMErrorTypeTable.put(new XMLErrorCode(
421:                            XMLMessageFormatter.XML_DOMAIN,
422:                            "QuoteRequiredInSystemID"), "wf-invalid-character");
423:                    fgDOMErrorTypeTable.put(new XMLErrorCode(
424:                            XMLMessageFormatter.XML_DOMAIN,
425:                            "SystemIDUnterminated"), "wf-invalid-character");
426:                    fgDOMErrorTypeTable
427:                            .put(new XMLErrorCode(
428:                                    XMLMessageFormatter.XML_DOMAIN,
429:                                    "SpaceRequiredAfterPUBLIC"),
430:                                    "wf-invalid-character");
431:                    fgDOMErrorTypeTable.put(new XMLErrorCode(
432:                            XMLMessageFormatter.XML_DOMAIN,
433:                            "QuoteRequiredInPublicID"), "wf-invalid-character");
434:                    fgDOMErrorTypeTable.put(new XMLErrorCode(
435:                            XMLMessageFormatter.XML_DOMAIN,
436:                            "PublicIDUnterminated"), "wf-invalid-character");
437:                    fgDOMErrorTypeTable
438:                            .put(new XMLErrorCode(
439:                                    XMLMessageFormatter.XML_DOMAIN,
440:                                    "PubidCharIllegal"), "wf-invalid-character");
441:                    fgDOMErrorTypeTable.put(new XMLErrorCode(
442:                            XMLMessageFormatter.XML_DOMAIN,
443:                            "SpaceRequiredBetweenPublicAndSystem"),
444:                            "wf-invalid-character");
445:                    fgDOMErrorTypeTable
446:                            .put(
447:                                    new XMLErrorCode(
448:                                            XMLMessageFormatter.XML_DOMAIN,
449:                                            "MSG_SPACE_REQUIRED_BEFORE_ROOT_ELEMENT_TYPE_IN_DOCTYPEDECL"),
450:                                    "wf-invalid-character-in-node-name"); // considered error in name of node (which follows !DOCTYPE) 
451:                    fgDOMErrorTypeTable.put(new XMLErrorCode(
452:                            XMLMessageFormatter.XML_DOMAIN,
453:                            "MSG_ROOT_ELEMENT_TYPE_REQUIRED"),
454:                            "wf-invalid-character-in-node-name");
455:                    fgDOMErrorTypeTable.put(new XMLErrorCode(
456:                            XMLMessageFormatter.XML_DOMAIN,
457:                            "DoctypedeclUnterminated"),
458:                            "wf-invalid-character-in-node-name");
459:                    fgDOMErrorTypeTable.put(new XMLErrorCode(
460:                            XMLMessageFormatter.XML_DOMAIN,
461:                            "PEReferenceWithinMarkup"), "wf-invalid-character");
462:                    fgDOMErrorTypeTable.put(new XMLErrorCode(
463:                            XMLMessageFormatter.XML_DOMAIN,
464:                            "MSG_MARKUP_NOT_RECOGNIZED_IN_DTD"),
465:                            "wf-invalid-character");
466:                    fgDOMErrorTypeTable
467:                            .put(
468:                                    new XMLErrorCode(
469:                                            XMLMessageFormatter.XML_DOMAIN,
470:                                            "MSG_SPACE_REQUIRED_BEFORE_ELEMENT_TYPE_IN_ELEMENTDECL"),
471:                                    "wf-invalid-character");
472:                    fgDOMErrorTypeTable.put(new XMLErrorCode(
473:                            XMLMessageFormatter.XML_DOMAIN,
474:                            "MSG_ELEMENT_TYPE_REQUIRED_IN_ELEMENTDECL"),
475:                            "wf-invalid-character");
476:                    fgDOMErrorTypeTable
477:                            .put(
478:                                    new XMLErrorCode(
479:                                            XMLMessageFormatter.XML_DOMAIN,
480:                                            "MSG_SPACE_REQUIRED_BEFORE_CONTENTSPEC_IN_ELEMENTDECL"),
481:                                    "wf-invalid-character");
482:                    fgDOMErrorTypeTable.put(new XMLErrorCode(
483:                            XMLMessageFormatter.XML_DOMAIN,
484:                            "MSG_CONTENTSPEC_REQUIRED_IN_ELEMENTDECL"),
485:                            "wf-invalid-character");
486:                    fgDOMErrorTypeTable.put(new XMLErrorCode(
487:                            XMLMessageFormatter.XML_DOMAIN,
488:                            "ElementDeclUnterminated"), "wf-invalid-character");
489:                    fgDOMErrorTypeTable
490:                            .put(
491:                                    new XMLErrorCode(
492:                                            XMLMessageFormatter.XML_DOMAIN,
493:                                            "MSG_OPEN_PAREN_OR_ELEMENT_TYPE_REQUIRED_IN_CHILDREN"),
494:                                    "wf-invalid-character");
495:                    fgDOMErrorTypeTable.put(new XMLErrorCode(
496:                            XMLMessageFormatter.XML_DOMAIN,
497:                            "MSG_CLOSE_PAREN_REQUIRED_IN_CHILDREN"),
498:                            "wf-invalid-character");
499:                    fgDOMErrorTypeTable.put(new XMLErrorCode(
500:                            XMLMessageFormatter.XML_DOMAIN,
501:                            "MSG_ELEMENT_TYPE_REQUIRED_IN_MIXED_CONTENT"),
502:                            "wf-invalid-character");
503:                    fgDOMErrorTypeTable.put(new XMLErrorCode(
504:                            XMLMessageFormatter.XML_DOMAIN,
505:                            "MSG_CLOSE_PAREN_REQUIRED_IN_MIXED"),
506:                            "wf-invalid-character");
507:                    fgDOMErrorTypeTable
508:                            .put(new XMLErrorCode(
509:                                    XMLMessageFormatter.XML_DOMAIN,
510:                                    "MixedContentUnterminated"),
511:                                    "wf-invalid-character");
512:                    fgDOMErrorTypeTable
513:                            .put(
514:                                    new XMLErrorCode(
515:                                            XMLMessageFormatter.XML_DOMAIN,
516:                                            "MSG_SPACE_REQUIRED_BEFORE_ELEMENT_TYPE_IN_ATTLISTDECL"),
517:                                    "wf-invalid-character");
518:                    fgDOMErrorTypeTable.put(new XMLErrorCode(
519:                            XMLMessageFormatter.XML_DOMAIN,
520:                            "MSG_ELEMENT_TYPE_REQUIRED_IN_ATTLISTDECL"),
521:                            "wf-invalid-character");
522:                    fgDOMErrorTypeTable
523:                            .put(
524:                                    new XMLErrorCode(
525:                                            XMLMessageFormatter.XML_DOMAIN,
526:                                            "MSG_SPACE_REQUIRED_BEFORE_ATTRIBUTE_NAME_IN_ATTDEF"),
527:                                    "wf-invalid-character");
528:                    fgDOMErrorTypeTable.put(new XMLErrorCode(
529:                            XMLMessageFormatter.XML_DOMAIN,
530:                            "AttNameRequiredInAttDef"), "wf-invalid-character");
531:                    fgDOMErrorTypeTable.put(new XMLErrorCode(
532:                            XMLMessageFormatter.XML_DOMAIN,
533:                            "MSG_SPACE_REQUIRED_BEFORE_ATTTYPE_IN_ATTDEF"),
534:                            "wf-invalid-character");
535:                    fgDOMErrorTypeTable.put(new XMLErrorCode(
536:                            XMLMessageFormatter.XML_DOMAIN,
537:                            "AttTypeRequiredInAttDef"), "wf-invalid-character");
538:                    fgDOMErrorTypeTable.put(new XMLErrorCode(
539:                            XMLMessageFormatter.XML_DOMAIN,
540:                            "MSG_SPACE_REQUIRED_BEFORE_DEFAULTDECL_IN_ATTDEF"),
541:                            "wf-invalid-character");
542:                    fgDOMErrorTypeTable.put(new XMLErrorCode(
543:                            XMLMessageFormatter.XML_DOMAIN,
544:                            "MSG_DUPLICATE_ATTRIBUTE_DEFINITION"),
545:                            "wf-invalid-character");
546:                    fgDOMErrorTypeTable
547:                            .put(
548:                                    new XMLErrorCode(
549:                                            XMLMessageFormatter.XML_DOMAIN,
550:                                            "MSG_SPACE_REQUIRED_AFTER_NOTATION_IN_NOTATIONTYPE"),
551:                                    "wf-invalid-character");
552:                    fgDOMErrorTypeTable.put(new XMLErrorCode(
553:                            XMLMessageFormatter.XML_DOMAIN,
554:                            "MSG_OPEN_PAREN_REQUIRED_IN_NOTATIONTYPE"),
555:                            "wf-invalid-character");
556:                    fgDOMErrorTypeTable.put(new XMLErrorCode(
557:                            XMLMessageFormatter.XML_DOMAIN,
558:                            "MSG_NAME_REQUIRED_IN_NOTATIONTYPE"),
559:                            "wf-invalid-character");
560:                    fgDOMErrorTypeTable
561:                            .put(new XMLErrorCode(
562:                                    XMLMessageFormatter.XML_DOMAIN,
563:                                    "NotationTypeUnterminated"),
564:                                    "wf-invalid-character");
565:                    fgDOMErrorTypeTable.put(new XMLErrorCode(
566:                            XMLMessageFormatter.XML_DOMAIN,
567:                            "MSG_NMTOKEN_REQUIRED_IN_ENUMERATION"),
568:                            "wf-invalid-character");
569:                    fgDOMErrorTypeTable.put(new XMLErrorCode(
570:                            XMLMessageFormatter.XML_DOMAIN,
571:                            "EnumerationUnterminated"), "wf-invalid-character");
572:                    fgDOMErrorTypeTable.put(new XMLErrorCode(
573:                            XMLMessageFormatter.XML_DOMAIN,
574:                            "MSG_DISTINCT_TOKENS_IN_ENUMERATION"),
575:                            "wf-invalid-character");
576:                    fgDOMErrorTypeTable.put(new XMLErrorCode(
577:                            XMLMessageFormatter.XML_DOMAIN,
578:                            "MSG_DISTINCT_NOTATION_IN_ENUMERATION"),
579:                            "wf-invalid-character");
580:                    fgDOMErrorTypeTable.put(new XMLErrorCode(
581:                            XMLMessageFormatter.XML_DOMAIN,
582:                            "MSG_SPACE_REQUIRED_AFTER_FIXED_IN_DEFAULTDECL"),
583:                            "wf-invalid-character");
584:                    fgDOMErrorTypeTable.put(new XMLErrorCode(
585:                            XMLMessageFormatter.XML_DOMAIN,
586:                            "IncludeSectUnterminated"), "wf-invalid-character");
587:                    fgDOMErrorTypeTable.put(new XMLErrorCode(
588:                            XMLMessageFormatter.XML_DOMAIN,
589:                            "IgnoreSectUnterminated"), "wf-invalid-character");
590:                    fgDOMErrorTypeTable.put(new XMLErrorCode(
591:                            XMLMessageFormatter.XML_DOMAIN,
592:                            "NameRequiredInPEReference"),
593:                            "wf-invalid-character");
594:                    fgDOMErrorTypeTable.put(new XMLErrorCode(
595:                            XMLMessageFormatter.XML_DOMAIN,
596:                            "SemicolonRequiredInPEReference"),
597:                            "wf-invalid-character");
598:                    fgDOMErrorTypeTable
599:                            .put(
600:                                    new XMLErrorCode(
601:                                            XMLMessageFormatter.XML_DOMAIN,
602:                                            "MSG_SPACE_REQUIRED_BEFORE_ENTITY_NAME_IN_ENTITYDECL"),
603:                                    "wf-invalid-character-in-node-name"); // considered error in name of node (which follows !ENTITY)
604:                    fgDOMErrorTypeTable.put(new XMLErrorCode(
605:                            XMLMessageFormatter.XML_DOMAIN,
606:                            "MSG_SPACE_REQUIRED_BEFORE_PERCENT_IN_PEDECL"),
607:                            "wf-invalid-character-in-node-name"); // considered error in name of node (which follows !ENTITY %)
608:                    fgDOMErrorTypeTable.put(new XMLErrorCode(
609:                            XMLMessageFormatter.XML_DOMAIN,
610:                            "MSG_SPACE_REQUIRED_BEFORE_ENTITY_NAME_IN_PEDECL"),
611:                            "wf-invalid-character-in-node-name"); // considered error in name of node (which follows !ENTITY %)
612:                    fgDOMErrorTypeTable.put(new XMLErrorCode(
613:                            XMLMessageFormatter.XML_DOMAIN,
614:                            "MSG_ENTITY_NAME_REQUIRED_IN_ENTITYDECL"),
615:                            "wf-invalid-character-in-node-name"); // considered error in name of node (which follows !ENTITY)
616:                    fgDOMErrorTypeTable
617:                            .put(
618:                                    new XMLErrorCode(
619:                                            XMLMessageFormatter.XML_DOMAIN,
620:                                            "MSG_SPACE_REQUIRED_AFTER_ENTITY_NAME_IN_ENTITYDECL"),
621:                                    "wf-invalid-character-in-node-name"); // considered error in name of node 
622:                    fgDOMErrorTypeTable
623:                            .put(
624:                                    new XMLErrorCode(
625:                                            XMLMessageFormatter.XML_DOMAIN,
626:                                            "MSG_SPACE_REQUIRED_BEFORE_NOTATION_NAME_IN_UNPARSED_ENTITYDECL"),
627:                                    "wf-invalid-character");
628:                    fgDOMErrorTypeTable
629:                            .put(
630:                                    new XMLErrorCode(
631:                                            XMLMessageFormatter.XML_DOMAIN,
632:                                            "MSG_SPACE_REQUIRED_BEFORE_NDATA_IN_UNPARSED_ENTITYDECL"),
633:                                    "wf-invalid-character");
634:                    fgDOMErrorTypeTable
635:                            .put(
636:                                    new XMLErrorCode(
637:                                            XMLMessageFormatter.XML_DOMAIN,
638:                                            "MSG_NOTATION_NAME_REQUIRED_FOR_UNPARSED_ENTITYDECL"),
639:                                    "wf-invalid-character");
640:                    fgDOMErrorTypeTable.put(new XMLErrorCode(
641:                            XMLMessageFormatter.XML_DOMAIN,
642:                            "EntityDeclUnterminated"),
643:                            "wf-invalid-character-in-node-name");
644:                    fgDOMErrorTypeTable.put(new XMLErrorCode(
645:                            XMLMessageFormatter.XML_DOMAIN,
646:                            "MSG_DUPLICATE_ENTITY_DEFINITION"),
647:                            "wf-invalid-character-in-node-name");
648:                    fgDOMErrorTypeTable.put(new XMLErrorCode(
649:                            XMLMessageFormatter.XML_DOMAIN,
650:                            "ExternalIDRequired"), "wf-invalid-character");
651:                    fgDOMErrorTypeTable
652:                            .put(
653:                                    new XMLErrorCode(
654:                                            XMLMessageFormatter.XML_DOMAIN,
655:                                            "MSG_SPACE_REQUIRED_BEFORE_PUBIDLITERAL_IN_EXTERNALID"),
656:                                    "wf-invalid-character");
657:                    fgDOMErrorTypeTable
658:                            .put(
659:                                    new XMLErrorCode(
660:                                            XMLMessageFormatter.XML_DOMAIN,
661:                                            "MSG_SPACE_REQUIRED_AFTER_PUBIDLITERAL_IN_EXTERNALID"),
662:                                    "wf-invalid-character");
663:                    fgDOMErrorTypeTable
664:                            .put(
665:                                    new XMLErrorCode(
666:                                            XMLMessageFormatter.XML_DOMAIN,
667:                                            "MSG_SPACE_REQUIRED_BEFORE_SYSTEMLITERAL_IN_EXTERNALID"),
668:                                    "wf-invalid-character");
669:                    fgDOMErrorTypeTable.put(new XMLErrorCode(
670:                            XMLMessageFormatter.XML_DOMAIN,
671:                            "MSG_URI_FRAGMENT_IN_SYSTEMID"),
672:                            "wf-invalid-character");
673:                    fgDOMErrorTypeTable
674:                            .put(
675:                                    new XMLErrorCode(
676:                                            XMLMessageFormatter.XML_DOMAIN,
677:                                            "MSG_SPACE_REQUIRED_BEFORE_NOTATION_NAME_IN_NOTATIONDECL"),
678:                                    "wf-invalid-character-in-node-name"); // considered error in name of node, which follows !NOTATION
679:                    fgDOMErrorTypeTable.put(new XMLErrorCode(
680:                            XMLMessageFormatter.XML_DOMAIN,
681:                            "MSG_NOTATION_NAME_REQUIRED_IN_NOTATIONDECL"),
682:                            "wf-invalid-character-in-node-name"); // considered error in name of node, which follows !NOTATION
683:                    fgDOMErrorTypeTable
684:                            .put(
685:                                    new XMLErrorCode(
686:                                            XMLMessageFormatter.XML_DOMAIN,
687:                                            "MSG_SPACE_REQUIRED_AFTER_NOTATION_NAME_IN_NOTATIONDECL"),
688:                                    "wf-invalid-character-in-node-name"); // considered error in name of node, which follows !NOTATION
689:                    fgDOMErrorTypeTable.put(new XMLErrorCode(
690:                            XMLMessageFormatter.XML_DOMAIN,
691:                            "ExternalIDorPublicIDRequired"),
692:                            "wf-invalid-character");
693:                    fgDOMErrorTypeTable.put(new XMLErrorCode(
694:                            XMLMessageFormatter.XML_DOMAIN,
695:                            "NotationDeclUnterminated"),
696:                            "wf-invalid-character-in-node-name");
697:                    fgDOMErrorTypeTable.put(new XMLErrorCode(
698:                            XMLMessageFormatter.XML_DOMAIN,
699:                            "ReferenceToExternalEntity"),
700:                            "wf-invalid-character");
701:                    fgDOMErrorTypeTable.put(new XMLErrorCode(
702:                            XMLMessageFormatter.XML_DOMAIN,
703:                            "ReferenceToUnparsedEntity"),
704:                            "wf-invalid-character");
705:
706:                    // REVISIT: do EntityNotDeclared, RecursiveReference, RecursiveGeneralReference, RecursivePEReference belong here?
707:                    fgDOMErrorTypeTable.put(new XMLErrorCode(
708:                            XMLMessageFormatter.XML_DOMAIN,
709:                            "EncodingNotSupported"), "unsupported-encoding");
710:                    fgDOMErrorTypeTable
711:                            .put(new XMLErrorCode(
712:                                    XMLMessageFormatter.XML_DOMAIN,
713:                                    "EncodingRequired"), "unsupported-encoding");
714:                    fgDOMErrorTypeTable.put(new XMLErrorCode(
715:                            XMLMessageFormatter.XML_DOMAIN, "IllegalQName"),
716:                            "wf-invalid-character-in-node-name");
717:                    fgDOMErrorTypeTable.put(new XMLErrorCode(
718:                            XMLMessageFormatter.XML_DOMAIN,
719:                            "ElementXMLNSPrefix"),
720:                            "wf-invalid-character-in-node-name");
721:                    fgDOMErrorTypeTable.put(new XMLErrorCode(
722:                            XMLMessageFormatter.XML_DOMAIN,
723:                            "ElementPrefixUnbound"),
724:                            "wf-invalid-character-in-node-name");
725:                    fgDOMErrorTypeTable.put(new XMLErrorCode(
726:                            XMLMessageFormatter.XML_DOMAIN,
727:                            "AttributePrefixUnbound"),
728:                            "wf-invalid-character-in-node-name");
729:                    fgDOMErrorTypeTable.put(new XMLErrorCode(
730:                            XMLMessageFormatter.XML_DOMAIN,
731:                            "EmptyPrefixedAttName"),
732:                            "wf-invalid-character-in-node-name");
733:                    fgDOMErrorTypeTable.put(new XMLErrorCode(
734:                            XMLMessageFormatter.XML_DOMAIN, "PrefixDeclared"),
735:                            "wf-invalid-character-in-node-name");
736:                }
737:
738:                public static String getDOMErrorType(XMLErrorCode error) {
739:                    return (String) fgDOMErrorTypeTable.get(error);
740:                }
741:
742:                private DOMErrorTypeMap() {
743:                }
744:            }
745:
746:        } // class DOMErrorHandlerWrapper
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.