juergen 2004/02/11 05:50:35
Modified: webdavclient/clientlib/src/java/org/apache/webdav/lib/methods
XMLResponseMethodBase.java
Log:
removed the ugly printlns from the xml parser in case of the response body is html.
Revision Changes Path
1.4 +102 -4
jakarta-slide/webdavclient/clientlib/src/java/org/apache/webdav/lib/methods/XMLResponseMethodBase.java
Index: XMLResponseMethodBase.java
===================================================================
RCS file:
/home/cvs/jakarta-slide/webdavclient/clientlib/src/java/org/apache/webdav/lib/methods/XMLResponseMethodBase.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- XMLResponseMethodBase.java 11 Feb 2004 11:30:52 -0000 1.3
+++ XMLResponseMethodBase.java 11 Feb 2004 13:50:35 -0000 1.4
@@ -5,7 +5,7 @@
*
* ====================================================================
*
- * Copyright 1999-2002 The Apache Software Foundation
+ * Copyright 1999-2002 The Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -55,7 +55,10 @@
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
+import org.xml.sax.ErrorHandler;
import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
/**
* Utility class for XML response parsing.
@@ -269,6 +272,7 @@
if (builder == null) {
try {
+ // TODO: avoid the newInstance call for each method instance for
performance reasons.
DocumentBuilderFactory factory =
DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(true);
@@ -281,6 +285,8 @@
try {
+ // avoid ugly printlns from the default error handler.
+ builder.setErrorHandler(new DummyErrorHandler());
responseDocument = builder.parse(new InputSource(input));
} catch (Exception e) {
@@ -611,5 +617,97 @@
protected void setResponseHashtable(Hashtable h){
responseHashtable = h;
}
+
+
+
+
+private static class DummyErrorHandler implements ErrorHandler {
+
+
+ /**
+ * Receive notification of a warning.
+ *
+ * <p>SAX parsers will use this method to report conditions that
+ * are not errors or fatal errors as defined by the XML 1.0
+ * recommendation. The default behaviour is to take no action.</p>
+ *
+ * <p>The SAX parser must continue to provide normal parsing events
+ * after invoking this method: it should still be possible for the
+ * application to process the document through to the end.</p>
+ *
+ * <p>Filters may use this method to report other, non-XML warnings
+ * as well.</p>
+ *
+ * @param exception The warning information encapsulated in a
+ * SAX parse exception.
+ * @exception org.xml.sax.SAXException Any SAX exception, possibly
+ * wrapping another exception.
+ * @see org.xml.sax.SAXParseException
+ */
+ public void warning(SAXParseException exception) throws SAXException
+ {
+ // System.out.println("warning: " + exception.getMessage());
+ }
+
+ /**
+ * Receive notification of a recoverable error.
+ *
+ * <p>This corresponds to the definition of "error" in section 1.2
+ * of the W3C XML 1.0 Recommendation. For example, a validating
+ * parser would use this callback to report the violation of a
+ * validity constraint. The default behaviour is to take no
+ * action.</p>
+ *
+ * <p>The SAX parser must continue to provide normal parsing events
+ * after invoking this method: it should still be possible for the
+ * application to process the document through to the end. If the
+ * application cannot do so, then the parser should report a fatal
+ * error even if the XML 1.0 recommendation does not require it to
+ * do so.</p>
+ *
+ * <p>Filters may use this method to report other, non-XML errors
+ * as well.</p>
+ *
+ * @param exception The error information encapsulated in a
+ * SAX parse exception.
+ * @exception org.xml.sax.SAXException Any SAX exception, possibly
+ * wrapping another exception.
+ * @see org.xml.sax.SAXParseException
+ */
+ public void error(SAXParseException exception) throws SAXException
+ {
+ // System.out.println("error: " + exception.getMessage());
+ }
+
+ /**
+ * Receive notification of a non-recoverable error.
+ *
+ * <p>This corresponds to the definition of "fatal error" in
+ * section 1.2 of the W3C XML 1.0 Recommendation. For example, a
+ * parser would use this callback to report the violation of a
+ * well-formedness constraint.</p>
+ *
+ * <p>The application must assume that the document is unusable
+ * after the parser has invoked this method, and should continue
+ * (if at all) only for the sake of collecting addition error
+ * messages: in fact, SAX parsers are free to stop reporting any
+ * other events once this method has been invoked.</p>
+ *
+ * @param exception The error information encapsulated in a
+ * SAX parse exception.
+ * @exception org.xml.sax.SAXException Any SAX exception, possibly
+ * wrapping another exception.
+ * @see org.xml.sax.SAXParseException
+ */
+ public void fatalError(SAXParseException exception) throws SAXException
+ {
+ // System.out.println("fatal: " + exception.getMessage());
+ }
+
+}
+
+
+
+
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]