src/share/jaxws_classes/com/sun/tools/internal/xjc/reader/xmlschema/parser/SchemaConstraintChecker.java

changeset 368
0989ad8c0860
parent 286
f50545b5e2f1
child 408
b0610cd08440
equal deleted inserted replaced
366:8c0b6bccfe47 368:0989ad8c0860
1 /* 1 /*
2 * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 * 4 *
5 * This code is free software; you can redistribute it and/or modify it 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 6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this 7 * published by the Free Software Foundation. Oracle designates this
34 34
35 import com.sun.tools.internal.xjc.ConsoleErrorReporter; 35 import com.sun.tools.internal.xjc.ConsoleErrorReporter;
36 import com.sun.tools.internal.xjc.ErrorReceiver; 36 import com.sun.tools.internal.xjc.ErrorReceiver;
37 import com.sun.tools.internal.xjc.util.ErrorReceiverFilter; 37 import com.sun.tools.internal.xjc.util.ErrorReceiverFilter;
38 38
39 import com.sun.xml.internal.bind.v2.util.XmlFactory;
39 import org.w3c.dom.ls.LSInput; 40 import org.w3c.dom.ls.LSInput;
40 import org.w3c.dom.ls.LSResourceResolver; 41 import org.w3c.dom.ls.LSResourceResolver;
41 import org.xml.sax.EntityResolver; 42 import org.xml.sax.EntityResolver;
42 import org.xml.sax.InputSource; 43 import org.xml.sax.InputSource;
43 import org.xml.sax.SAXException; 44 import org.xml.sax.SAXException;
58 * @param schemas Schema files to be checked. 59 * @param schemas Schema files to be checked.
59 * @param errorHandler detected errors will be reported to this handler. 60 * @param errorHandler detected errors will be reported to this handler.
60 * @return true if there was no error, false if there were errors. 61 * @return true if there was no error, false if there were errors.
61 */ 62 */
62 public static boolean check(InputSource[] schemas, 63 public static boolean check(InputSource[] schemas,
63 ErrorReceiver errorHandler, final EntityResolver entityResolver) { 64 ErrorReceiver errorHandler,
65 final EntityResolver entityResolver,
66 boolean disableXmlSecurity) {
64 67
65 ErrorReceiverFilter errorFilter = new ErrorReceiverFilter(errorHandler); 68 ErrorReceiverFilter errorFilter = new ErrorReceiverFilter(errorHandler);
66 boolean hadErrors = false; 69 boolean hadErrors = false;
67 70
68 SchemaFactory sf = SchemaFactory.newInstance(W3C_XML_SCHEMA_NS_URI); 71 SchemaFactory sf = XmlFactory.createSchemaFactory(W3C_XML_SCHEMA_NS_URI, disableXmlSecurity);
69 sf.setErrorHandler(errorFilter); 72 sf.setErrorHandler(errorFilter);
70 if( entityResolver != null ) { 73 if( entityResolver != null ) {
71 sf.setResourceResolver(new LSResourceResolver() { 74 sf.setResourceResolver(new LSResourceResolver() {
72 public LSInput resolveResource(String type, String namespaceURI, String publicId, String systemId, String baseURI) { 75 public LSInput resolveResource(String type, String namespaceURI, String publicId, String systemId, String baseURI) {
73 try { 76 try {
119 public static void main(String[] args) throws IOException { 122 public static void main(String[] args) throws IOException {
120 InputSource[] sources = new InputSource[args.length]; 123 InputSource[] sources = new InputSource[args.length];
121 for (int i = 0; i < args.length; i++) 124 for (int i = 0; i < args.length; i++)
122 sources[i] = new InputSource(new File(args[i]).toURL().toExternalForm()); 125 sources[i] = new InputSource(new File(args[i]).toURL().toExternalForm());
123 126
124 check(sources, new ConsoleErrorReporter(), null); 127 check(sources, new ConsoleErrorReporter(), null, true);
125 } 128 }
126 } 129 }

mercurial