Path: blob/master/src/java.xml/share/classes/javax/xml/validation/SchemaFactory.java
40948 views
/*1* Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package javax.xml.validation;2627import com.sun.org.apache.xerces.internal.jaxp.validation.XMLSchemaFactory;28import java.io.File;29import java.net.URL;30import javax.xml.transform.Source;31import javax.xml.transform.stream.StreamSource;32import jdk.xml.internal.SecuritySupport;33import org.w3c.dom.ls.LSResourceResolver;34import org.xml.sax.ErrorHandler;35import org.xml.sax.SAXException;36import org.xml.sax.SAXNotRecognizedException;37import org.xml.sax.SAXNotSupportedException;38import org.xml.sax.SAXParseException;3940/**41* Factory that creates {@link Schema} objects. Entry-point to42* the validation API.43*44* <p>45* {@link SchemaFactory} is a schema compiler. It reads external46* representations of schemas and prepares them for validation.47*48* <p>49* The {@link SchemaFactory} class is not thread-safe. In other words,50* it is the application's responsibility to ensure that at most51* one thread is using a {@link SchemaFactory} object at any52* given moment. Implementations are encouraged to mark methods53* as {@code synchronized} to protect themselves from broken clients.54*55* <p>56* {@link SchemaFactory} is not re-entrant. While one of the57* {@code newSchema} methods is being invoked, applications58* may not attempt to recursively invoke the {@code newSchema} method,59* even from the same thread.60*61* <h2><a id="schemaLanguage"></a>Schema Language</h2>62* <p>63* This spec uses a namespace URI to designate a schema language.64* The following table shows the values defined by this specification.65* <p>66* To be compliant with the spec, the implementation67* is only required to support W3C XML Schema 1.0. However,68* if it chooses to support other schema languages listed here,69* it must conform to the relevant behaviors described in this spec.70*71* <p>72* Schema languages not listed here are expected to73* introduce their own URIs to represent themselves.74* The {@link SchemaFactory} class is capable of locating other75* implementations for other schema languages at run-time.76*77* <p>78* Note that because the XML DTD is strongly tied to the parsing process79* and has a significant effect on the parsing process, it is impossible80* to define the DTD validation as a process independent from parsing.81* For this reason, this specification does not define the semantics for82* the XML DTD. This doesn't prohibit implementors from implementing it83* in a way they see fit, but <em>users are warned that any DTD84* validation implemented on this interface necessarily deviate from85* the XML DTD semantics as defined in the XML 1.0</em>.86*87* <table class="striped">88* <caption>URIs for Supported Schema languages</caption>89* <thead>90* <tr>91* <th scope="col">value</th>92* <th scope="col">language</th>93* </tr>94* </thead>95* <tbody>96* <tr>97* <th scope="row">{@link javax.xml.XMLConstants#W3C_XML_SCHEMA_NS_URI} ("{@code http://www.w3.org/2001/XMLSchema}")</th>98* <td><a href="http://www.w3.org/TR/xmlschema-1">W3C XML Schema 1.0</a></td>99* </tr>100* <tr>101* <th scope="row">{@link javax.xml.XMLConstants#RELAXNG_NS_URI} ("{@code http://relaxng.org/ns/structure/1.0}")</th>102* <td><a href="http://www.relaxng.org/">RELAX NG 1.0</a></td>103* </tr>104* </tbody>105* </table>106*107* @author Kohsuke Kawaguchi108* @author Neeraj Bajaj109*110* @since 1.5111*/112public abstract class SchemaFactory {113114/**115* Constructor for derived classes.116*117* <p>The constructor does nothing.118*119* <p>Derived classes must create {@link SchemaFactory} objects that have120* {@code null} {@link ErrorHandler} and121* {@code null} {@link LSResourceResolver}.122*/123protected SchemaFactory() {124}125126/**127* Creates a new instance of the {@code SchemaFactory} builtin128* system-default implementation.129*130* @implSpec The {@code SchemaFactory} builtin131* system-default implementation is only required to support the132* <a href="http://www.w3.org/TR/xmlschema-1">W3C XML Schema 1.0</a>,133* but may support additional <a href="#schemaLanguage">schema languages</a>.134*135* @return A new instance of the {@code SchemaFactory} builtin136* system-default implementation.137*138* @since 9139*/140public static SchemaFactory newDefaultInstance() {141return new XMLSchemaFactory();142}143144/**145* Obtains a new instance of a {@code SchemaFactory} that supports146* the specified schema language. This method uses the147* <a href="../../../module-summary.html#LookupMechanism">JAXP Lookup Mechanism</a>148* to determine and load the {@code SchemaFactory} implementation that supports149* the specified schema language.150*151* <h4>Tip for Trouble-shooting:</h4>152* <p>See {@link java.util.Properties#load(java.io.InputStream)} for153* exactly how a property file is parsed. In particular, colons ':'154* need to be escaped in a property file, so make sure schema language155* URIs are properly escaped in it. For example:156* <pre>157* http\://www.w3.org/2001/XMLSchema=org.acme.foo.XSSchemaFactory158* </pre>159*160* @param schemaLanguage161* Specifies the schema language which the returned162* SchemaFactory will understand. See163* <a href="#schemaLanguage">the list of available164* schema languages</a> for the possible values.165*166* @return New instance of a {@code SchemaFactory}167*168* @throws IllegalArgumentException169* If no implementation of the schema language is available.170* @throws NullPointerException171* If the {@code schemaLanguage} parameter is null.172* @throws SchemaFactoryConfigurationError173* If a configuration error is encountered.174*175* @see #newInstance(String schemaLanguage, String factoryClassName, ClassLoader classLoader)176*/177public static SchemaFactory newInstance(String schemaLanguage) {178ClassLoader cl;179cl = SecuritySupport.getContextClassLoader();180181if (cl == null) {182//cl = ClassLoader.getSystemClassLoader();183//use the current class loader184cl = SchemaFactory.class.getClassLoader();185}186187SchemaFactory f = new SchemaFactoryFinder(cl).newFactory(schemaLanguage);188if (f == null) {189throw new IllegalArgumentException(190"No SchemaFactory"191+ " that implements the schema language specified by: " + schemaLanguage192+ " could be loaded");193}194return f;195}196197/**198* Obtain a new instance of a {@code SchemaFactory} from class name. {@code SchemaFactory}199* is returned if specified factory class name supports the specified schema language.200* This function is useful when there are multiple providers in the classpath.201* It gives more control to the application as it can specify which provider202* should be loaded.203*204* <h4>Tip for Trouble-shooting</h4>205* <p>Setting the {@code jaxp.debug} system property will cause206* this method to print a lot of debug messages207* to {@code System.err} about what it is doing and where it is looking at.208*209* <p> If you have problems try:210* <pre>211* java -Djaxp.debug=1 YourProgram ....212* </pre>213*214* @param schemaLanguage Specifies the schema language which the returned215* {@code SchemaFactory} will understand. See216* <a href="#schemaLanguage">the list of available217* schema languages</a> for the possible values.218*219* @param factoryClassName fully qualified factory class name that provides implementation of {@code javax.xml.validation.SchemaFactory}.220*221* @param classLoader {@code ClassLoader} used to load the factory class. If {@code null}222* current {@code Thread}'s context classLoader is used to load the factory class.223*224* @return New instance of a {@code SchemaFactory}225*226* @throws IllegalArgumentException227* if {@code factoryClassName} is {@code null}, or228* the factory class cannot be loaded, instantiated or doesn't229* support the schema language specified in {@code schemLanguage}230* parameter.231*232* @throws NullPointerException233* If the {@code schemaLanguage} parameter is null.234*235* @see #newInstance(String schemaLanguage)236*237* @since 1.6238*/239public static SchemaFactory newInstance(String schemaLanguage, String factoryClassName, ClassLoader classLoader){240ClassLoader cl = classLoader;241242if (cl == null) {243cl = SecuritySupport.getContextClassLoader();244}245246SchemaFactory f = new SchemaFactoryFinder(cl).createInstance(factoryClassName);247if (f == null) {248throw new IllegalArgumentException(249"Factory " + factoryClassName250+ " could not be loaded to implement the schema language specified by: " + schemaLanguage);251}252//if this factory supports the given schemalanguage return this factory else thrown exception253if(f.isSchemaLanguageSupported(schemaLanguage)){254return f;255}else{256throw new IllegalArgumentException(257"Factory " + f.getClass().getName()258+ " does not implement the schema language specified by: " + schemaLanguage);259}260261}262263/**264* Is specified schema supported by this {@code SchemaFactory}?265*266* @param schemaLanguage Specifies the schema language which the returned {@code SchemaFactory} will understand.267* {@code schemaLanguage} must specify a <a href="#schemaLanguage">valid</a> schema language.268*269* @return {@code true} if {@code SchemaFactory} supports {@code schemaLanguage}, else {@code false}.270*271* @throws NullPointerException If {@code schemaLanguage} is {@code null}.272* @throws IllegalArgumentException If {@code schemaLanguage.length() == 0}273* or {@code schemaLanguage} does not specify a <a href="#schemaLanguage">valid</a> schema language.274*/275public abstract boolean isSchemaLanguageSupported(String schemaLanguage);276277/**278* Look up the value of a feature flag.279*280* <p>The feature name is any fully-qualified URI. It is281* possible for a {@link SchemaFactory} to recognize a feature name but282* temporarily be unable to return its value.283*284* <p>Implementors are free (and encouraged) to invent their own features,285* using names built on their own URIs.286*287* @param name The feature name, which is a non-null fully-qualified URI.288*289* @return The current value of the feature (true or false).290*291* @throws SAXNotRecognizedException If the feature292* value can't be assigned or retrieved.293* @throws SAXNotSupportedException When the294* {@link SchemaFactory} recognizes the feature name but295* cannot determine its value at this time.296* @throws NullPointerException If {@code name} is {@code null}.297*298* @see #setFeature(String, boolean)299*/300public boolean getFeature(String name)301throws SAXNotRecognizedException, SAXNotSupportedException {302303if (name == null) {304throw new NullPointerException("the name parameter is null");305}306throw new SAXNotRecognizedException(name);307}308309/**310* Set a feature for this {@code SchemaFactory},311* {@link Schema}s created by this factory, and by extension,312* {@link Validator}s and {@link ValidatorHandler}s created by313* those {@link Schema}s.314*315* <p>Implementors and developers should pay particular attention316* to how the special {@link Schema} object returned by {@link317* #newSchema()} is processed. In some cases, for example, when the318* {@code SchemaFactory} and the class actually loading the319* schema come from different implementations, it may not be possible320* for {@code SchemaFactory} features to be inherited automatically.321* Developers should322* make sure that features, such as secure processing, are explicitly323* set in both places.324*325* <p>The feature name is any fully-qualified URI. It is326* possible for a {@link SchemaFactory} to expose a feature value but327* to be unable to change the current value.328*329* <p>All implementations are required to support the {@link javax.xml.XMLConstants#FEATURE_SECURE_PROCESSING} feature.330* When the feature is:331* <ul>332* <li>333* {@code true}: the implementation will limit XML processing to conform to implementation limits.334* Examples include entity expansion limits and XML Schema constructs that would consume large amounts of resources.335* If XML processing is limited for security reasons, it will be reported via a call to the registered336* {@link ErrorHandler#fatalError(SAXParseException exception)}.337* See {@link #setErrorHandler(ErrorHandler errorHandler)}.338* </li>339* <li>340* {@code false}: the implementation will processing XML according to the XML specifications without341* regard to possible implementation limits.342* </li>343* </ul>344*345* @param name The feature name, which is a non-null fully-qualified URI.346* @param value The requested value of the feature (true or false).347*348* @throws SAXNotRecognizedException If the feature349* value can't be assigned or retrieved.350* @throws SAXNotSupportedException When the351* {@link SchemaFactory} recognizes the feature name but352* cannot set the requested value.353* @throws NullPointerException If {@code name} is {@code null}.354*355* @see #getFeature(String)356*/357public void setFeature(String name, boolean value)358throws SAXNotRecognizedException, SAXNotSupportedException {359360if (name == null) {361throw new NullPointerException("the name parameter is null");362}363throw new SAXNotRecognizedException(name);364}365366/**367* Set the value of a property.368*369* <p>The property name is any fully-qualified URI. It is370* possible for a {@link SchemaFactory} to recognize a property name but371* to be unable to change the current value.372*373* <p>374* All implementations that implement JAXP 1.5 or newer are required to375* support the {@link javax.xml.XMLConstants#ACCESS_EXTERNAL_DTD} and376* {@link javax.xml.XMLConstants#ACCESS_EXTERNAL_SCHEMA} properties.377*378* <ul>379* <li>380* <p>Access to external DTDs in Schema files is restricted to the protocols381* specified by the {@link javax.xml.XMLConstants#ACCESS_EXTERNAL_DTD} property.382* If access is denied during the creation of new Schema due to the restriction383* of this property, {@link org.xml.sax.SAXException} will be thrown by the384* {@link #newSchema(Source)} or {@link #newSchema(File)}385* or {@link #newSchema(URL)} or {@link #newSchema(Source[])} method.386*387* <p>Access to external DTDs in xml source files is restricted to the protocols388* specified by the {@link javax.xml.XMLConstants#ACCESS_EXTERNAL_DTD} property.389* If access is denied during validation due to the restriction390* of this property, {@link org.xml.sax.SAXException} will be thrown by the391* {@link javax.xml.validation.Validator#validate(Source)} or392* {@link javax.xml.validation.Validator#validate(Source, Result)} method.393*394* <p>Access to external reference set by the schemaLocation attribute is395* restricted to the protocols specified by the396* {@link javax.xml.XMLConstants#ACCESS_EXTERNAL_SCHEMA} property.397* If access is denied during validation due to the restriction of this property,398* {@link org.xml.sax.SAXException} will be thrown by the399* {@link javax.xml.validation.Validator#validate(Source)} or400* {@link javax.xml.validation.Validator#validate(Source, Result)} method.401*402* <p>Access to external reference set by the Import403* and Include element is restricted to the protocols specified by the404* {@link javax.xml.XMLConstants#ACCESS_EXTERNAL_SCHEMA} property.405* If access is denied during the creation of new Schema due to the restriction406* of this property, {@link org.xml.sax.SAXException} will be thrown by the407* {@link #newSchema(Source)} or {@link #newSchema(File)}408* or {@link #newSchema(URL)} or {@link #newSchema(Source[])} method.409* </li>410* </ul>411*412* @param name The property name, which is a non-null fully-qualified URI.413* @param object The requested value for the property.414*415* @throws SAXNotRecognizedException If the property416* value can't be assigned or retrieved.417* @throws SAXNotSupportedException When the418* {@link SchemaFactory} recognizes the property name but419* cannot set the requested value.420* @throws NullPointerException If {@code name} is {@code null}.421*/422public void setProperty(String name, Object object)423throws SAXNotRecognizedException, SAXNotSupportedException {424425if (name == null) {426throw new NullPointerException("the name parameter is null");427}428throw new SAXNotRecognizedException(name);429}430431/**432* Look up the value of a property.433*434* <p>The property name is any fully-qualified URI. It is435* possible for a {@link SchemaFactory} to recognize a property name but436* temporarily be unable to return its value.437*438* <p>{@link SchemaFactory}s are not required to recognize any specific439* property names.440*441* <p>Implementors are free (and encouraged) to invent their own properties,442* using names built on their own URIs.443*444* @param name The property name, which is a non-null fully-qualified URI.445*446* @return The current value of the property.447*448* @throws SAXNotRecognizedException If the property449* value can't be assigned or retrieved.450* @throws SAXNotSupportedException When the451* XMLReader recognizes the property name but452* cannot determine its value at this time.453* @throws NullPointerException If {@code name} is {@code null}.454*455* @see #setProperty(String, Object)456*/457public Object getProperty(String name)458throws SAXNotRecognizedException, SAXNotSupportedException {459460if (name == null) {461throw new NullPointerException("the name parameter is null");462}463throw new SAXNotRecognizedException(name);464}465466/**467* Sets the {@link ErrorHandler} to receive errors encountered468* during the {@code newSchema} method invocation.469*470* <p>471* Error handler can be used to customize the error handling process472* during schema parsing. When an {@link ErrorHandler} is set,473* errors found during the parsing of schemas will be first sent474* to the {@link ErrorHandler}.475*476* <p>477* The error handler can abort the parsing of a schema immediately478* by throwing {@link SAXException} from the handler. Or for example479* it can print an error to the screen and try to continue the480* processing by returning normally from the {@link ErrorHandler}481*482* <p>483* If any {@link Throwable} (or instances of its derived classes)484* is thrown from an {@link ErrorHandler},485* the caller of the {@code newSchema} method will be thrown486* the same {@link Throwable} object.487*488* <p>489* {@link SchemaFactory} is not allowed to490* throw {@link SAXException} without first reporting it to491* {@link ErrorHandler}.492*493* <p>494* Applications can call this method even during a {@link Schema}495* is being parsed.496*497* <p>498* When the {@link ErrorHandler} is null, the implementation will499* behave as if the following {@link ErrorHandler} is set:500* <pre>501* class DraconianErrorHandler implements {@link ErrorHandler} {502* public void fatalError( {@link org.xml.sax.SAXParseException} e ) throws {@link SAXException} {503* throw e;504* }505* public void error( {@link org.xml.sax.SAXParseException} e ) throws {@link SAXException} {506* throw e;507* }508* public void warning( {@link org.xml.sax.SAXParseException} e ) throws {@link SAXException} {509* // noop510* }511* }512* </pre>513*514* <p>515* When a new {@link SchemaFactory} object is created, initially516* this field is set to null. This field will <em>NOT</em> be517* inherited to {@link Schema}s, {@link Validator}s, or518* {@link ValidatorHandler}s that are created from this {@link SchemaFactory}.519*520* @param errorHandler A new error handler to be set.521* This parameter can be {@code null}.522*/523public abstract void setErrorHandler(ErrorHandler errorHandler);524525/**526* Gets the current {@link ErrorHandler} set to this {@link SchemaFactory}.527*528* @return529* This method returns the object that was last set through530* the {@link #setErrorHandler(ErrorHandler)} method, or null531* if that method has never been called since this {@link SchemaFactory}532* has created.533*534* @see #setErrorHandler(ErrorHandler)535*/536public abstract ErrorHandler getErrorHandler();537538/**539* Sets the {@link LSResourceResolver} to customize540* resource resolution when parsing schemas.541*542* <p>543* {@link SchemaFactory} uses a {@link LSResourceResolver}544* when it needs to locate external resources while parsing schemas,545* although exactly what constitutes "locating external resources" is546* up to each schema language. For example, for W3C XML Schema,547* this includes files {@code <include>}d or {@code <import>}ed,548* and DTD referenced from schema files, etc.549*550* <p>551* Applications can call this method even during a {@link Schema}552* is being parsed.553*554* <p>555* When the {@link LSResourceResolver} is null, the implementation will556* behave as if the following {@link LSResourceResolver} is set:557* <pre>558* class DumbDOMResourceResolver implements {@link LSResourceResolver} {559* public {@link org.w3c.dom.ls.LSInput} resolveResource(560* String publicId, String systemId, String baseURI) {561*562* return null; // always return null563* }564* }565* </pre>566*567* <p>568* If a {@link LSResourceResolver} throws a {@link RuntimeException}569* (or instances of its derived classes),570* then the {@link SchemaFactory} will abort the parsing and571* the caller of the {@code newSchema} method will receive572* the same {@link RuntimeException}.573*574* <p>575* When a new {@link SchemaFactory} object is created, initially576* this field is set to null. This field will <em>NOT</em> be577* inherited to {@link Schema}s, {@link Validator}s, or578* {@link ValidatorHandler}s that are created from this {@link SchemaFactory}.579*580* @param resourceResolver581* A new resource resolver to be set. This parameter can be null.582*/583public abstract void setResourceResolver(LSResourceResolver resourceResolver);584585/**586* Gets the current {@link LSResourceResolver} set to this {@link SchemaFactory}.587*588* @return589* This method returns the object that was last set through590* the {@link #setResourceResolver(LSResourceResolver)} method, or null591* if that method has never been called since this {@link SchemaFactory}592* has created.593*594* @see #setErrorHandler(ErrorHandler)595*/596public abstract LSResourceResolver getResourceResolver();597598/**599* Parses the specified source as a schema and returns it as a schema.600*601* <p>This is a convenience method for {@link #newSchema(Source[] schemas)}.602*603* @param schema Source that represents a schema.604*605* @return New {@code Schema} from parsing {@code schema}.606*607* @throws SAXException If a SAX error occurs during parsing.608* @throws NullPointerException if {@code schema} is null.609*/610public Schema newSchema(Source schema) throws SAXException {611return newSchema(new Source[]{schema});612}613614/**615* Parses the specified {@code File} as a schema and returns it as a {@code Schema}.616*617* <p>This is a convenience method for {@link #newSchema(Source schema)}.618*619* @param schema File that represents a schema.620*621* @return New {@code Schema} from parsing {@code schema}.622*623* @throws SAXException If a SAX error occurs during parsing.624* @throws NullPointerException if {@code schema} is null.625*/626public Schema newSchema(File schema) throws SAXException {627return newSchema(new StreamSource(schema));628}629630/**631* Parses the specified {@code URL} as a schema and returns it as a {@code Schema}.632*633* <p>This is a convenience method for {@link #newSchema(Source schema)}.634*635* @param schema {@code URL} that represents a schema.636*637* @return New {@code Schema} from parsing {@code schema}.638*639* @throws SAXException If a SAX error occurs during parsing.640* @throws NullPointerException if {@code schema} is null.641*/642public Schema newSchema(URL schema) throws SAXException {643return newSchema(new StreamSource(schema.toExternalForm()));644}645646/**647* Parses the specified source(s) as a schema and returns it as a schema.648*649* <p>650* The callee will read all the {@link Source}s and combine them into a651* single schema. The exact semantics of the combination depends on the schema652* language that this {@link SchemaFactory} object is created for.653*654* <p>655* When an {@link ErrorHandler} is set, the callee will report all the errors656* found in sources to the handler. If the handler throws an exception, it will657* abort the schema compilation and the same exception will be thrown from658* this method. Also, after an error is reported to a handler, the callee is allowed659* to abort the further processing by throwing it. If an error handler is not set,660* the callee will throw the first error it finds in the sources.661*662* <h4>W3C XML Schema 1.0</h4>663* <p>664* The resulting schema contains components from the specified sources.665* The same result would be achieved if all these sources were666* imported, using appropriate values for schemaLocation and namespace,667* into a single schema document with a different targetNamespace668* and no components of its own, if the import elements were given669* in the same order as the sources. Section 4.2.3 of the XML Schema670* recommendation describes the options processors have in this671* regard. While a processor should be consistent in its treatment of672* JAXP schema sources and XML Schema imports, the behaviour between673* JAXP-compliant parsers may vary; in particular, parsers may choose674* to ignore all but the first {@code <import>} for a given namespace,675* regardless of information provided in schemaLocation.676*677* <p>678* If the parsed set of schemas includes error(s) as679* specified in the section 5.1 of the XML Schema spec, then680* the error must be reported to the {@link ErrorHandler}.681*682* <h4>RELAX NG</h4>683*684* <p>For RELAX NG, this method must throw {@link UnsupportedOperationException}685* if {@code schemas.length!=1}.686*687*688* @param schemas689* inputs to be parsed. {@link SchemaFactory} is required690* to recognize {@link javax.xml.transform.sax.SAXSource},691* {@link StreamSource},692* {@link javax.xml.transform.stax.StAXSource},693* and {@link javax.xml.transform.dom.DOMSource}.694* Input schemas must be XML documents or695* XML elements and must not be null. For backwards compatibility,696* the results of passing anything other than697* a document or element are implementation-dependent.698* Implementations must either recognize and process the input699* or thrown an IllegalArgumentException.700*701* @return702* Always return a non-null valid {@link Schema} object.703* Note that when an error has been reported, there is no704* guarantee that the returned {@link Schema} object is705* meaningful.706*707* @throws SAXException708* If an error is found during processing the specified inputs.709* When an {@link ErrorHandler} is set, errors are reported to710* there first. See {@link #setErrorHandler(ErrorHandler)}.711* @throws NullPointerException712* If the {@code schemas} parameter itself is null or713* any item in the array is null.714* @throws IllegalArgumentException715* If any item in the array is not recognized by this method.716* @throws UnsupportedOperationException717* If the schema language doesn't support this operation.718*/719public abstract Schema newSchema(Source[] schemas) throws SAXException;720721/**722* Creates a special {@link Schema} object.723*724* <p>The exact semantics of the returned {@link Schema} object725* depend on the schema language for which this {@link SchemaFactory}726* is created.727*728* <p>Also, implementations are allowed to use implementation-specific729* property/feature to alter the semantics of this method.730*731* <p>Implementors and developers should pay particular attention732* to how the features set on this {@link SchemaFactory} are733* processed by this special {@link Schema}.734* In some cases, for example, when the735* {@link SchemaFactory} and the class actually loading the736* schema come from different implementations, it may not be possible737* for {@link SchemaFactory} features to be inherited automatically.738* Developers should739* make sure that features, such as secure processing, are explicitly740* set in both places.741*742* <h4>W3C XML Schema 1.0</h4>743* <p>744* For XML Schema, this method creates a {@link Schema} object that745* performs validation by using location hints specified in documents.746*747* <p>748* The returned {@link Schema} object assumes that if documents749* refer to the same URL in the schema location hints,750* they will always resolve to the same schema document. This751* asusmption allows implementations to reuse parsed results of752* schema documents so that multiple validations against the same753* schema will run faster.754*755* <p>756* Note that the use of schema location hints introduces a757* vulnerability to denial-of-service attacks.758*759*760* <h4>RELAX NG</h4>761* <p>762* RELAX NG does not support this operation.763*764* @return765* Always return non-null valid {@link Schema} object.766*767* @throws UnsupportedOperationException768* If this operation is not supported by the callee.769* @throws SAXException770* If this operation is supported but failed for some reason.771*/772public abstract Schema newSchema() throws SAXException;773}774775776