< prev index next >

src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/reader/xmlschema/parser/SchemaConstraintChecker.java

Print this page


   1 /*
   2  * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


  31 import javax.xml.transform.Source;
  32 import javax.xml.transform.sax.SAXSource;
  33 import javax.xml.validation.SchemaFactory;
  34 
  35 import com.sun.tools.internal.xjc.ConsoleErrorReporter;
  36 import com.sun.tools.internal.xjc.ErrorReceiver;
  37 import com.sun.tools.internal.xjc.util.ErrorReceiverFilter;
  38 
  39 import com.sun.xml.internal.bind.v2.util.XmlFactory;
  40 import org.w3c.dom.ls.LSInput;
  41 import org.w3c.dom.ls.LSResourceResolver;
  42 import org.xml.sax.EntityResolver;
  43 import org.xml.sax.InputSource;
  44 import org.xml.sax.SAXException;
  45 
  46 import static javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI;
  47 
  48 /**
  49  * Checks XML Schema XML representation constraints and
  50  * schema component constraints by using JAXP 1.3 validation framework.
  51  * <p/>
  52  *
  53  * @author Kohsuke Kawaguchi (kohsuke.kawaguchi@sun.com)
  54  * @author Ryan Shoemaker (ryan.shoemaker@sun.com)
  55  */
  56 public class SchemaConstraintChecker {
  57 
  58     /**
  59      * @param schemas      Schema files to be checked.
  60      * @param errorHandler detected errors will be reported to this handler.
  61      * @return true if there was no error, false if there were errors.
  62      */
  63     public static boolean check(InputSource[] schemas,
  64                                 ErrorReceiver errorHandler,
  65                                 final EntityResolver entityResolver,
  66                                 boolean disableXmlSecurity) {
  67 
  68         ErrorReceiverFilter errorFilter = new ErrorReceiverFilter(errorHandler);
  69         boolean hadErrors = false;
  70 
  71         SchemaFactory sf = XmlFactory.createSchemaFactory(W3C_XML_SCHEMA_NS_URI, disableXmlSecurity);


   1 /*
   2  * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


  31 import javax.xml.transform.Source;
  32 import javax.xml.transform.sax.SAXSource;
  33 import javax.xml.validation.SchemaFactory;
  34 
  35 import com.sun.tools.internal.xjc.ConsoleErrorReporter;
  36 import com.sun.tools.internal.xjc.ErrorReceiver;
  37 import com.sun.tools.internal.xjc.util.ErrorReceiverFilter;
  38 
  39 import com.sun.xml.internal.bind.v2.util.XmlFactory;
  40 import org.w3c.dom.ls.LSInput;
  41 import org.w3c.dom.ls.LSResourceResolver;
  42 import org.xml.sax.EntityResolver;
  43 import org.xml.sax.InputSource;
  44 import org.xml.sax.SAXException;
  45 
  46 import static javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI;
  47 
  48 /**
  49  * Checks XML Schema XML representation constraints and
  50  * schema component constraints by using JAXP 1.3 validation framework.
  51  * <p>
  52  *
  53  * @author Kohsuke Kawaguchi (kohsuke.kawaguchi@sun.com)
  54  * @author Ryan Shoemaker (ryan.shoemaker@sun.com)
  55  */
  56 public class SchemaConstraintChecker {
  57 
  58     /**
  59      * @param schemas      Schema files to be checked.
  60      * @param errorHandler detected errors will be reported to this handler.
  61      * @return true if there was no error, false if there were errors.
  62      */
  63     public static boolean check(InputSource[] schemas,
  64                                 ErrorReceiver errorHandler,
  65                                 final EntityResolver entityResolver,
  66                                 boolean disableXmlSecurity) {
  67 
  68         ErrorReceiverFilter errorFilter = new ErrorReceiverFilter(errorHandler);
  69         boolean hadErrors = false;
  70 
  71         SchemaFactory sf = XmlFactory.createSchemaFactory(W3C_XML_SCHEMA_NS_URI, disableXmlSecurity);


< prev index next >