You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-commits@axis.apache.org by ve...@apache.org on 2018/01/06 10:46:45 UTC

svn commit: r1820382 - in /axis/axis2/java/core/trunk/modules/schema-validation/src/main/java/org/apache/axis2/validation: SchemaFactoryErrorHandler.java SchemaValidationHandler.java

Author: veithen
Date: Sat Jan  6 10:46:45 2018
New Revision: 1820382

URL: http://svn.apache.org/viewvc?rev=1820382&view=rev
Log:
Improve error reporting in the schema-validation module.

Added:
    axis/axis2/java/core/trunk/modules/schema-validation/src/main/java/org/apache/axis2/validation/SchemaFactoryErrorHandler.java   (with props)
Modified:
    axis/axis2/java/core/trunk/modules/schema-validation/src/main/java/org/apache/axis2/validation/SchemaValidationHandler.java

Added: axis/axis2/java/core/trunk/modules/schema-validation/src/main/java/org/apache/axis2/validation/SchemaFactoryErrorHandler.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/schema-validation/src/main/java/org/apache/axis2/validation/SchemaFactoryErrorHandler.java?rev=1820382&view=auto
==============================================================================
--- axis/axis2/java/core/trunk/modules/schema-validation/src/main/java/org/apache/axis2/validation/SchemaFactoryErrorHandler.java (added)
+++ axis/axis2/java/core/trunk/modules/schema-validation/src/main/java/org/apache/axis2/validation/SchemaFactoryErrorHandler.java Sat Jan  6 10:46:45 2018
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.axis2.validation;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.xml.sax.ErrorHandler;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+
+final class SchemaFactoryErrorHandler implements ErrorHandler {
+    private static final Log log = LogFactory.getLog(SchemaFactoryErrorHandler.class);
+
+    @Override
+    public void warning(SAXParseException exception) throws SAXException {
+        log.warn(exception.getMessage());
+    }
+
+    @Override
+    public void error(SAXParseException exception) throws SAXException {
+        throw exception;
+    }
+
+    @Override
+    public void fatalError(SAXParseException exception) throws SAXException {
+        throw exception;
+    }
+}

Propchange: axis/axis2/java/core/trunk/modules/schema-validation/src/main/java/org/apache/axis2/validation/SchemaFactoryErrorHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: axis/axis2/java/core/trunk/modules/schema-validation/src/main/java/org/apache/axis2/validation/SchemaValidationHandler.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/schema-validation/src/main/java/org/apache/axis2/validation/SchemaValidationHandler.java?rev=1820382&r1=1820381&r2=1820382&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/schema-validation/src/main/java/org/apache/axis2/validation/SchemaValidationHandler.java (original)
+++ axis/axis2/java/core/trunk/modules/schema-validation/src/main/java/org/apache/axis2/validation/SchemaValidationHandler.java Sat Jan  6 10:46:45 2018
@@ -54,6 +54,7 @@ public class SchemaValidationHandler ext
             return InvocationResponse.CONTINUE;
         }
         SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
+        schemaFactory.setErrorHandler(new SchemaFactoryErrorHandler());
         List<Source> schemaSources = new ArrayList<Source>();
         for (XmlSchema schema : schemas) {
             MemoryBlob blob = Blobs.createMemoryBlob();