From: Alex L. <al...@jb...> - 2005-08-15 13:46:25
|
User: aloubyansky Date: 05/08/15 09:45:01 Modified: src/main/org/jboss/xb/binding Util.java Log: use custom error handler when parsing schemas Revision Changes Path 1.6 +12 -2 jboss-common/src/main/org/jboss/xb/binding/Util.java (In the diff below, changes in quantity of whitespace are not shown.) Index: Util.java =================================================================== RCS file: /cvsroot/jboss/jboss-common/src/main/org/jboss/xb/binding/Util.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -b -r1.5 -r1.6 --- Util.java 12 Aug 2005 09:35:52 -0000 1.5 +++ Util.java 15 Aug 2005 13:45:01 -0000 1.6 @@ -13,6 +13,7 @@ import org.jboss.util.Classes; import org.jboss.xb.binding.sunday.unmarshalling.SchemaBindingResolver; import org.jboss.xb.binding.sunday.unmarshalling.LSInputAdaptor; +import org.jboss.xb.binding.sunday.unmarshalling.XsdBinder; import org.jboss.logging.Logger; import org.xml.sax.Attributes; import org.apache.xerces.xs.XSModel; @@ -27,7 +28,7 @@ * Various utilities for XML binding. * * @author <a href="mailto:al...@jb...">Alexey Loubyansky</a> - * @version <tt>$Revision: 1.5 $</tt> + * @version <tt>$Revision: 1.6 $</tt> */ public final class Util { @@ -140,7 +141,6 @@ // skip protocol part, i.e. http://, urn:// while(src[srcInd++] != ':') { - ; } while(src[srcInd] == '/') @@ -274,6 +274,7 @@ } XSModel model = schemaLoader.loadURI(xsdURL); + setDOMErrorHandler(schemaLoader); if(model == null) { throw new IllegalArgumentException("Invalid URI for schema: " + xsdURL); @@ -293,6 +294,7 @@ XSImplementation impl = getXSImplementation(); XSLoader schemaLoader = impl.createXSLoader(null); + setDOMErrorHandler(schemaLoader); if(schemaResolver != null) { setResourceResolver(schemaLoader, schemaResolver); @@ -312,6 +314,7 @@ XSImplementation impl = getXSImplementation(); XSLoader schemaLoader = impl.createXSLoader(null); + setDOMErrorHandler(schemaLoader); if(schemaResolver != null) { setResourceResolver(schemaLoader, schemaResolver); @@ -331,6 +334,7 @@ XSImplementation impl = getXSImplementation(); XSLoader schemaLoader = impl.createXSLoader(null); + setDOMErrorHandler(schemaLoader); return schemaLoader.load(input); } @@ -380,6 +384,12 @@ ); } + private static void setDOMErrorHandler(XSLoader schemaLoader) + { + DOMConfiguration config = schemaLoader.getConfig(); + config.setParameter("error-handler", XsdBinder.XsdBinderErrorHandler.INSTANCE); + } + private static XSImplementation getXSImplementation() { // Get DOM Implementation using DOM Registry |