elena 2002/08/11 13:29:19
Modified: java/src/org/apache/xerces/parsers DOMBuilderImpl.java
Log:
canSetFeature now accepts Xerces features.
If exception occurs during parsing, we now report it via DOMErrorHandler.
Revision Changes Path
1.19 +35 -17
xml-xerces/java/src/org/apache/xerces/parsers/DOMBuilderImpl.java
Index: DOMBuilderImpl.java
===================================================================
RCS file:
/home/cvs/xml-xerces/java/src/org/apache/xerces/parsers/DOMBuilderImpl.java,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- DOMBuilderImpl.java 9 Aug 2002 15:18:19 -0000 1.18
+++ DOMBuilderImpl.java 11 Aug 2002 20:29:19 -0000 1.19
@@ -76,7 +76,7 @@
import org.w3c.dom.ls.DOMBuilderFilter;
import org.w3c.dom.ls.DOMInputSource;
-
+import org.apache.xerces.dom.DOMErrorImpl;
import org.apache.xerces.impl.Constants;
import org.apache.xerces.util.DOMEntityResolverWrapper;
import org.apache.xerces.util.SymbolTable;
@@ -141,6 +141,8 @@
protected String fSchemaType = XML_SCHEMA_VALIDATION;
protected final static boolean DEBUG = false;
+
+ protected DOMErrorHandlerWrapper fErrorHandler = null;
//
// Constructors
//
@@ -293,18 +295,10 @@
* result in implementation dependent behavour.
*/
public DOMErrorHandler getErrorHandler() {
- DOMErrorHandler errorHandler = null;
- try {
- DOMErrorHandler domErrorHandler =
- (DOMErrorHandler)fConfiguration.getProperty(ERROR_HANDLER);
- if (domErrorHandler != null &&
- domErrorHandler instanceof DOMErrorHandlerWrapper) {
- errorHandler =
((DOMErrorHandlerWrapper)domErrorHandler).getErrorHandler();
- }
- } catch (XMLConfigurationException e) {
-
+ if (fErrorHandler != null) {
+ return fErrorHandler.getErrorHandler();
}
- return errorHandler;
+ return null;
}
/**
@@ -320,8 +314,9 @@
*/
public void setErrorHandler(DOMErrorHandler errorHandler) {
try {
+ fErrorHandler = new DOMErrorHandlerWrapper(errorHandler);
fConfiguration.setProperty(ERROR_HANDLER,
- new DOMErrorHandlerWrapper(errorHandler));
+ fErrorHandler);
} catch (XMLConfigurationException e) {
}
@@ -445,7 +440,16 @@
name.equals(Constants.DOM_WHITESPACE_IN_ELEMENT_CONTENT)) {
return true;
}
- return false;
+
+
+ // Recognize Xerces features.
+ try {
+ fConfiguration.getFeature(name);
+ return true;
+ } catch (XMLConfigurationException e){
+ return false;
+ }
+
}
/**
@@ -501,7 +505,14 @@
try {
parse(source);
} catch (Exception e){
- // REVISIT: report exception via the error handler
+ if (fErrorHandler != null) {
+ DOMErrorImpl error = new DOMErrorImpl();
+ error.fException = e;
+ error.fMessage = e.getMessage();
+ error.fSeverity = error.SEVERITY_ERROR;
+ fErrorHandler.getErrorHandler().handleError(error);
+
+ }
if (DEBUG) {
e.printStackTrace();
}
@@ -525,7 +536,14 @@
try {
parse(xmlInputSource);
} catch (Exception e) {
- // REVISIT: report exception via the error handler
+ if (fErrorHandler != null) {
+ DOMErrorImpl error = new DOMErrorImpl();
+ error.fException = e;
+ error.fMessage = e.getMessage();
+ error.fSeverity = error.SEVERITY_ERROR;
+ fErrorHandler.getErrorHandler().handleError(error);
+
+ }
if (DEBUG) {
e.printStackTrace();
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]