KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > xerces > util > DOMErrorHandlerWrapper


1 /*
2  * Copyright 2001, 2002, 2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16
17 package org.apache.xerces.util;
18
19 import org.apache.xerces.xni.XNIException;
20 import org.apache.xerces.xni.parser.XMLErrorHandler;
21 import org.apache.xerces.xni.parser.XMLParseException;
22                              
23 import org.w3c.dom.Node JavaDoc;
24 import org.w3c.dom.DOMError JavaDoc;
25 import org.w3c.dom.DOMLocator JavaDoc;
26 import org.w3c.dom.DOMErrorHandler JavaDoc;
27 import org.apache.xerces.dom.DOMErrorImpl;
28 import org.apache.xerces.dom.DOMLocatorImpl;
29 import org.apache.xerces.impl.msg.XMLMessageFormatter;
30
31 import java.io.PrintWriter JavaDoc;
32 import java.util.Hashtable JavaDoc;
33
34 /**
35  * This class handles DOM errors .
36  *
37  * @see DOMErrorHandler
38  *
39  * @author Gopal Sharma, SUN Microsystems Inc.
40  * @version $Id: DOMErrorHandlerWrapper.java,v 1.15 2005/05/02 21:48:51 mrglavas Exp $
41  */

42
43 // REVISIT: current implementations wraps error several times:
44
// XMLErrorReport.reportError creates XMLParserException (by wrapping all info)
45
// and goes via switch to send errors.
46
// DOMErrorHandlerWrapper catches calls, copies info from XMLParserException and
47
// sends one call back to the application
48
// I think we can avoid this indirection if we modify XMLErrorReporter. --el
49

50 public class DOMErrorHandlerWrapper
51     implements XMLErrorHandler, DOMErrorHandler JavaDoc {
52
53
54     
55     // It keeps the reference of DOMErrorHandler of application
56
protected DOMErrorHandler JavaDoc fDomErrorHandler;
57
58     // Error Status
59
boolean eStatus = true ;
60
61     // Print writer
62
protected PrintWriter JavaDoc fOut;
63
64     // some components may set error node
65
// @see DOMNormalizer.
66
public Node JavaDoc fCurrentNode;
67
68     /** Error code for comparisons. **/
69     protected final XMLErrorCode fErrorCode = new XMLErrorCode(null, null);
70     
71     protected final DOMErrorImpl fDOMError = new DOMErrorImpl();
72     
73
74
75     //
76
// Constructors
77
//
78

79     // Default constructor /
80

81     public DOMErrorHandlerWrapper() {
82         fOut = new PrintWriter JavaDoc(System.err);
83     }
84
85
86     public DOMErrorHandlerWrapper(DOMErrorHandler JavaDoc domErrorHandler) {
87         fDomErrorHandler = domErrorHandler;
88     } // DOMErrorHandlerWrapper(DOMErrorHandler domErrorHandler)
89

90
91     //
92
// Public methods
93
//
94

95     /** Sets the DOM error handler. */
96     public void setErrorHandler(DOMErrorHandler JavaDoc errorHandler) {
97         fDomErrorHandler = errorHandler;
98     } // setErrorHandler(ErrorHandler)
99

100
101     public DOMErrorHandler JavaDoc getErrorHandler(){
102         return fDomErrorHandler;
103     } //getErrorHandler()
104

105     //
106
// XMLErrorHandler methods
107
//
108

109     /**
110      * Reports a warning. Warnings are non-fatal and can be safely ignored
111      * by most applications.
112      *
113      * @param domain The domain of the warning. The domain can be any
114      * string but is suggested to be a valid URI. The
115      * domain can be used to conveniently specify a web
116      * site location of the relevent specification or
117      * document pertaining to this warning.
118      * @param key The warning key. This key can be any string and
119      * is implementation dependent.
120      * @param exception Exception.
121      *
122      * @throws XNIException Thrown to signal that the parser should stop
123      * parsing the document.
124      */

125
126     public void warning(String JavaDoc domain, String JavaDoc key,
127                         XMLParseException exception) throws XNIException {
128         fDOMError.fSeverity = DOMError.SEVERITY_WARNING;
129         fDOMError.fException = exception;
130         // REVISIT: May need to lookup from DOMErrorTypeMap in the future.
131
fDOMError.fType = key;
132         fDOMError.fRelatedData = fDOMError.fMessage = exception.getMessage();
133         DOMLocatorImpl locator = fDOMError.fLocator;
134         if (locator != null) {
135             locator.fColumnNumber = exception.getColumnNumber();
136             locator.fLineNumber = exception.getLineNumber();
137             locator.fUtf16Offset = exception.getCharacterOffset();
138             locator.fUri = exception.getExpandedSystemId();
139             locator.fRelatedNode = fCurrentNode;
140         }
141         if (fDomErrorHandler != null) {
142             fDomErrorHandler.handleError(fDOMError);
143         }
144     } // warning(String,String,XMLParseException)
145

146     /**
147      * Reports an error. Errors are non-fatal and usually signify that the
148      * document is invalid with respect to its grammar(s).
149      *
150      * @param domain The domain of the error. The domain can be any
151      * string but is suggested to be a valid URI. The
152      * domain can be used to conveniently specify a web
153      * site location of the relevent specification or
154      * document pertaining to this error.
155      * @param key The error key. This key can be any string and
156      * is implementation dependent.
157      * @param exception Exception.
158      *
159      * @throws XNIException Thrown to signal that the parser should stop
160      * parsing the document.
161      */

162     public void error(String JavaDoc domain, String JavaDoc key,
163                       XMLParseException exception) throws XNIException {
164         fDOMError.fSeverity = DOMError.SEVERITY_ERROR;
165         fDOMError.fException = exception;
166         // REVISIT: May need to lookup from DOMErrorTypeMap in the future.
167
fDOMError.fType = key;
168         fDOMError.fRelatedData = fDOMError.fMessage = exception.getMessage();
169         DOMLocatorImpl locator = fDOMError.fLocator;
170         if (locator != null) {
171             locator.fColumnNumber = exception.getColumnNumber();
172             locator.fLineNumber = exception.getLineNumber();
173             locator.fUtf16Offset = exception.getCharacterOffset();
174             locator.fUri = exception.getExpandedSystemId();
175             locator.fRelatedNode= fCurrentNode;
176         }
177         if (fDomErrorHandler != null) {
178             fDomErrorHandler.handleError(fDOMError);
179         }
180     } // error(String,String,XMLParseException)
181

182     /**
183      * Report a fatal error. Fatal errors usually occur when the document
184      * is not well-formed and signifies that the parser cannot continue
185      * normal operation.
186      * <p>
187      * <strong>Note:</strong> The error handler should <em>always</em>
188      * throw an <code>XNIException</code> from this method. This exception
189      * can either be the same exception that is passed as a parameter to
190      * the method or a new XNI exception object. If the registered error
191      * handler fails to throw an exception, the continuing operation of
192      * the parser is undetermined.
193      *
194      * @param domain The domain of the fatal error. The domain can be
195      * any string but is suggested to be a valid URI. The
196      * domain can be used to conveniently specify a web
197      * site location of the relevent specification or
198      * document pertaining to this fatal error.
199      * @param key The fatal error key. This key can be any string
200      * and is implementation dependent.
201      * @param exception Exception.
202      *
203      * @throws XNIException Thrown to signal that the parser should stop
204      * parsing the document.
205      */

206     public void fatalError(String JavaDoc domain, String JavaDoc key,
207                            XMLParseException exception) throws XNIException {
208         fDOMError.fSeverity = DOMError.SEVERITY_FATAL_ERROR;
209         fDOMError.fException = exception;
210         fErrorCode.setValues(domain, key);
211         String JavaDoc domErrorType = DOMErrorTypeMap.getDOMErrorType(fErrorCode);
212         fDOMError.fType = (domErrorType != null) ? domErrorType : key;
213         fDOMError.fRelatedData = fDOMError.fMessage = exception.getMessage();
214         DOMLocatorImpl locator = fDOMError.fLocator;
215         if (locator != null) {
216             locator.fColumnNumber = exception.getColumnNumber();
217             locator.fLineNumber = exception.getLineNumber();
218             locator.fUtf16Offset = exception.getCharacterOffset();
219             locator.fUri = exception.getExpandedSystemId();
220             locator.fRelatedNode = fCurrentNode;
221         }
222         if (fDomErrorHandler != null) {
223             fDomErrorHandler.handleError(fDOMError);
224         }
225     } // fatalError(String,String,XMLParseException)
226

227
228     public boolean handleError(DOMError JavaDoc error) {
229         printError(error);
230         return eStatus;
231     }
232
233     /** Prints the error message. */
234
235     private void printError(DOMError JavaDoc error) {
236         int severity = error.getSeverity();
237         fOut.print("[");
238         if ( severity == DOMError.SEVERITY_WARNING) {
239             fOut.print("Warning");
240         } else if ( severity == DOMError.SEVERITY_ERROR) {
241             fOut.print("Error");
242         } else {
243             fOut.print("FatalError");
244             eStatus = false ; //REVISIT: Abort processing if fatal error, do we need to??
245
}
246         fOut.print("] ");
247         DOMLocator JavaDoc locator = error.getLocation();
248         if (locator != null) {
249             fOut.print(locator.getLineNumber());
250             fOut.print(":");
251             fOut.print(locator.getColumnNumber());
252             fOut.print(":");
253             fOut.print(locator.getByteOffset());
254             fOut.print(",");
255             fOut.print(locator.getUtf16Offset());
256             Node JavaDoc node = locator.getRelatedNode();
257             if (node != null) {
258                 fOut.print("[");
259                 fOut.print(node.getNodeName());
260                 fOut.print("]");
261             }
262             String JavaDoc systemId = locator.getUri();
263             if (systemId != null) {
264                 int index = systemId.lastIndexOf('/');
265                 if (index != -1)
266                     systemId = systemId.substring(index + 1);
267                 fOut.print(": ");
268                 fOut.print(systemId);
269             }
270
271         }
272
273         fOut.print(":");
274         fOut.print(error.getMessage());
275         fOut.println();
276         fOut.flush();
277
278     } // printError(DOMError)
279

280     /**
281      * A convenience class for converting between internal
282      * error codes and DOM error types.
283      */

284     private static class DOMErrorTypeMap {
285         
286         /** Map for converting internal error codes to DOM error types. **/
287         private static Hashtable JavaDoc fgDOMErrorTypeTable;
288         
289         static {
290             // initialize error type table: internal error codes (represented by domain and key) need to be mapped to a DOM error type.
291

292             // 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.
293

294             fgDOMErrorTypeTable = new Hashtable JavaDoc();
295             fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "InvalidCharInCDSect"), "wf-invalid-character");
296             fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "InvalidCharInContent"), "wf-invalid-character");
297             fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "TwoColonsInQName"), "wf-invalid-character-in-node-name");
298             fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "ColonNotLegalWithNS"), "wf-invalid-character-in-node-name");
299             fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "InvalidCharInProlog"), "wf-invalid-character"); // e.g. in Processing Instruction
300

301             // InvalidCharInXMLDecl omitted because XML declaration is not a DOM Node
302
fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "CDEndInContent"), "wf-invalid-character");
303             fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "CDSectUnterminated"), "wf-invalid-character");
304             fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "DoctypeNotAllowed"), "doctype-not-allowed");
305             fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "ETagRequired"), "wf-invalid-character-in-node-name");
306             fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "ElementUnterminated"), "wf-invalid-character-in-node-name");
307             fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "EqRequiredInAttribute"), "wf-invalid-character");
308             fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "OpenQuoteExpected"), "wf-invalid-character");
309             fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "CloseQuoteExpected"), "wf-invalid-character");
310             fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "ETagUnterminated"), "wf-invalid-character-in-node-name");
311             fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "MarkupNotRecognizedInContent"), "wf-invalid-character");
312             fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "DoctypeIllegalInContent"), "doctype-not-allowed");
313             fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "InvalidCharInAttValue"), "wf-invalid-character");
314             fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "InvalidCharInPI"), "wf-invalid-character");
315             fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "InvalidCharInInternalSubset"), "wf-invalid-character");
316             fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "QuoteRequiredInAttValue"), "wf-invalid-character");
317             fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "LessthanInAttValue"), "wf-invalid-character");
318             fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "AttributeValueUnterminated"), "wf-invalid-character");
319             fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "PITargetRequired"), "wf-invalid-character");
320             fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "SpaceRequiredInPI"), "wf-invalid-character");
321             fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "PIUnterminated"), "wf-invalid-character");
322             fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "ReservedPITarget"), "wf-invalid-character");
323             fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "PI_NOT_IN_ONE_ENTITY"), "wf-invalid-character");
324             fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "PINotInOneEntity"), "wf-invalid-character");
325             fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "EncodingDeclInvalid"), "unsupported-encoding");
326             fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "EncodingByteOrderUnsupported"), "unsupported-encoding");
327             fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "InvalidCharInEntityValue"), "wf-invalid-character-in-node-name");
328             fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "InvalidCharInExternalSubset"), "wf-invalid-character");
329             fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "InvalidCharInIgnoreSect"), "wf-invalid-character");
330             fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "InvalidCharInPublicID"), "wf-invalid-character");
331             fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "InvalidCharInSystemID"), "wf-invalid-character");
332             fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "SpaceRequiredAfterSYSTEM"), "wf-invalid-character");
333             fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "QuoteRequiredInSystemID"), "wf-invalid-character");
334             fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "SystemIDUnterminated"), "wf-invalid-character");
335             fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "SpaceRequiredAfterPUBLIC"), "wf-invalid-character");
336             fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "QuoteRequiredInPublicID"), "wf-invalid-character");
337             fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "PublicIDUnterminated"), "wf-invalid-character");
338             fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "PubidCharIllegal"), "wf-invalid-character");
339             fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "SpaceRequiredBetweenPublicAndSystem"), "wf-invalid-character");
340             fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "MSG_SPACE_REQUIRED_BEFORE_ROOT_ELEMENT_TYPE_IN_DOCTYPEDECL"), "wf-invalid-character-in-node-name"); // considered error in name of node (which follows !DOCTYPE)
341
fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "MSG_ROOT_ELEMENT_TYPE_REQUIRED"), "wf-invalid-character-in-node-name");
342             fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "DoctypedeclUnterminated"), "wf-invalid-character-in-node-name");
343             fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "PEReferenceWithinMarkup"), "wf-invalid-character");
344             fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "MSG_MARKUP_NOT_RECOGNIZED_IN_DTD"), "wf-invalid-character");
345             fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "MSG_SPACE_REQUIRED_BEFORE_ELEMENT_TYPE_IN_ELEMENTDECL"), "wf-invalid-character");
346             fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "MSG_ELEMENT_TYPE_REQUIRED_IN_ELEMENTDECL"), "wf-invalid-character");
347             fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "MSG_SPACE_REQUIRED_BEFORE_CONTENTSPEC_IN_ELEMENTDECL"), "wf-invalid-character");
348             fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "MSG_CONTENTSPEC_REQUIRED_IN_ELEMENTDECL"), "wf-invalid-character");
349             fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "ElementDeclUnterminated"), "wf-invalid-character");
350             fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "MSG_OPEN_PAREN_OR_ELEMENT_TYPE_REQUIRED_IN_CHILDREN"), "wf-invalid-character");
351             fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "MSG_CLOSE_PAREN_REQUIRED_IN_CHILDREN"), "wf-invalid-character");
352             fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "MSG_ELEMENT_TYPE_REQUIRED_IN_MIXED_CONTENT"), "wf-invalid-character");
353             fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "MSG_CLOSE_PAREN_REQUIRED_IN_MIXED"), "wf-invalid-character");
354             fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "MixedContentUnterminated"), "wf-invalid-character");
355             fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "MSG_SPACE_REQUIRED_BEFORE_ELEMENT_TYPE_IN_ATTLISTDECL"), "wf-invalid-character");
356             fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "MSG_ELEMENT_TYPE_REQUIRED_IN_ATTLISTDECL"), "wf-invalid-character");
357             fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "MSG_SPACE_REQUIRED_BEFORE_ATTRIBUTE_NAME_IN_ATTDEF"), "wf-invalid-character");
358             fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "AttNameRequiredInAttDef"), "wf-invalid-character");
359             fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "MSG_SPACE_REQUIRED_BEFORE_ATTTYPE_IN_ATTDEF"), "wf-invalid-character");
360             fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "AttTypeRequiredInAttDef"), "wf-invalid-character");
361             fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "MSG_SPACE_REQUIRED_BEFORE_DEFAULTDECL_IN_ATTDEF"), "wf-invalid-character");
362             fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "MSG_DUPLICATE_ATTRIBUTE_DEFINITION"), "wf-invalid-character");
363             fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "MSG_SPACE_REQUIRED_AFTER_NOTATION_IN_NOTATIONTYPE"), "wf-invalid-character");
364             fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "MSG_OPEN_PAREN_REQUIRED_IN_NOTATIONTYPE"), "wf-invalid-character");
365             fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "MSG_NAME_REQUIRED_IN_NOTATIONTYPE"), "wf-invalid-character");
366             fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "NotationTypeUnterminated"), "wf-invalid-character");
367             fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "MSG_NMTOKEN_REQUIRED_IN_ENUMERATION"), "wf-invalid-character");
368             fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "EnumerationUnterminated"), "wf-invalid-character");
369             fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "MSG_DISTINCT_TOKENS_IN_ENUMERATION"), "wf-invalid-character");
370             fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "MSG_DISTINCT_NOTATION_IN_ENUMERATION"), "wf-invalid-character");
371             fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "MSG_SPACE_REQUIRED_AFTER_FIXED_IN_DEFAULTDECL"), "wf-invalid-character");
372             fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "IncludeSectUnterminated"), "wf-invalid-character");
373             fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "IgnoreSectUnterminated"), "wf-invalid-character");
374             fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "NameRequiredInPEReference"), "wf-invalid-character");
375             fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "SemicolonRequiredInPEReference"), "wf-invalid-character");
376             fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "MSG_SPACE_REQUIRED_BEFORE_ENTITY_NAME_IN_ENTITYDECL"), "wf-invalid-character-in-node-name"); // considered error in name of node (which follows !ENTITY)
377
fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "MSG_SPACE_REQUIRED_BEFORE_PERCENT_IN_PEDECL"), "wf-invalid-character-in-node-name"); // considered error in name of node (which follows !ENTITY %)
378
fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "MSG_SPACE_REQUIRED_BEFORE_ENTITY_NAME_IN_PEDECL"), "wf-invalid-character-in-node-name"); // considered error in name of node (which follows !ENTITY %)
379
fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "MSG_ENTITY_NAME_REQUIRED_IN_ENTITYDECL"), "wf-invalid-character-in-node-name"); // considered error in name of node (which follows !ENTITY)
380
fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "MSG_SPACE_REQUIRED_AFTER_ENTITY_NAME_IN_ENTITYDECL"), "wf-invalid-character-in-node-name"); // considered error in name of node
381
fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "MSG_SPACE_REQUIRED_BEFORE_NOTATION_NAME_IN_UNPARSED_ENTITYDECL"), "wf-invalid-character");
382             fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "MSG_SPACE_REQUIRED_BEFORE_NDATA_IN_UNPARSED_ENTITYDECL"), "wf-invalid-character");
383             fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "MSG_NOTATION_NAME_REQUIRED_FOR_UNPARSED_ENTITYDECL"), "wf-invalid-character");
384             fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "EntityDeclUnterminated"), "wf-invalid-character-in-node-name");
385             fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "MSG_DUPLICATE_ENTITY_DEFINITION"), "wf-invalid-character-in-node-name");
386             fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "ExternalIDRequired"), "wf-invalid-character");
387             fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "MSG_SPACE_REQUIRED_BEFORE_PUBIDLITERAL_IN_EXTERNALID"), "wf-invalid-character");
388             fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "MSG_SPACE_REQUIRED_AFTER_PUBIDLITERAL_IN_EXTERNALID"), "wf-invalid-character");
389             fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "MSG_SPACE_REQUIRED_BEFORE_SYSTEMLITERAL_IN_EXTERNALID"), "wf-invalid-character");
390             fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "MSG_URI_FRAGMENT_IN_SYSTEMID"), "wf-invalid-character");
391             fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "MSG_SPACE_REQUIRED_BEFORE_NOTATION_NAME_IN_NOTATIONDECL"), "wf-invalid-character-in-node-name"); // considered error in name of node, which follows !NOTATION
392
fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "MSG_NOTATION_NAME_REQUIRED_IN_NOTATIONDECL"), "wf-invalid-character-in-node-name"); // considered error in name of node, which follows !NOTATION
393
fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "MSG_SPACE_REQUIRED_AFTER_NOTATION_NAME_IN_NOTATIONDECL"), "wf-invalid-character-in-node-name"); // considered error in name of node, which follows !NOTATION
394
fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "ExternalIDorPublicIDRequired"), "wf-invalid-character");
395             fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "NotationDeclUnterminated"), "wf-invalid-character-in-node-name");
396             fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "ReferenceToExternalEntity"), "wf-invalid-character");
397             fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "ReferenceToUnparsedEntity"), "wf-invalid-character");
398
399             // REVISIT: do EntityNotDeclared, RecursiveReference, RecursiveGeneralReference, RecursivePEReference belong here?
400
fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "EncodingNotSupported"), "unsupported-encoding");
401             fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "EncodingRequired"), "unsupported-encoding");
402             fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "IllegalQName"), "wf-invalid-character-in-node-name");
403             fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "ElementXMLNSPrefix"), "wf-invalid-character-in-node-name");
404             fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "ElementPrefixUnbound"), "wf-invalid-character-in-node-name");
405             fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "AttributePrefixUnbound"), "wf-invalid-character-in-node-name");
406             fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "EmptyPrefixedAttName"), "wf-invalid-character-in-node-name");
407             fgDOMErrorTypeTable.put(new XMLErrorCode(XMLMessageFormatter.XML_DOMAIN, "PrefixDeclared"), "wf-invalid-character-in-node-name");
408         }
409         
410         public static String JavaDoc getDOMErrorType (XMLErrorCode error) {
411             return (String JavaDoc) fgDOMErrorTypeTable.get(error);
412         }
413         
414         private DOMErrorTypeMap () {}
415     }
416
417 } // class DOMErrorHandlerWrapper
418
Popular Tags