1. // $Id: SchemaFactory.java,v 1.20.10.1.2.2 2004/06/11 14:59:49 ndw Exp $
  2. /*
  3. * @(#)SchemaFactory.java 1.10 04/07/26
  4. *
  5. * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
  6. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  7. */
  8. package javax.xml.validation;
  9. import java.io.File;
  10. import java.net.URL;
  11. import javax.xml.transform.Source;
  12. import javax.xml.transform.stream.StreamSource;
  13. import org.w3c.dom.ls.LSResourceResolver;
  14. import org.xml.sax.ErrorHandler;
  15. import org.xml.sax.SAXException;
  16. import org.xml.sax.SAXNotRecognizedException;
  17. import org.xml.sax.SAXNotSupportedException;
  18. /**
  19. * Factory that creates {@link Schema} objects. Entry-point to
  20. * the validation API.
  21. *
  22. * <p>
  23. * {@link SchemaFactory} is a schema compiler. It reads external
  24. * representations of schemas and prepares them for validation.
  25. *
  26. * <p>
  27. * The {@link SchemaFactory} class is not thread-safe. In other words,
  28. * it is the application's responsibility to ensure that at most
  29. * one thread is using a {@link SchemaFactory} object at any
  30. * given moment. Implementations are encouraged to mark methods
  31. * as <tt>synchronized</tt> to protect themselves from broken clients.
  32. *
  33. * <p>
  34. * {@link SchemaFactory} is not re-entrant. While one of the
  35. * <code>newSchema</code> methods is being invoked, applications
  36. * may not attempt to recursively invoke the <code>newSchema</code> method,
  37. * even from the same thread.
  38. *
  39. * <h2><a name="schemaLanguage"></a>Schema Language</h2>
  40. * <p>
  41. * This spec uses a namespace URI to designate a schema language.
  42. * The following table shows the values defined by this specification.
  43. * <p>
  44. * To be compliant with the spec, the implementation
  45. * is only required to support W3C XML Schema 1.0. However,
  46. * if it chooses to support other schema languages listed here,
  47. * it must conform to the relevant behaviors described in this spec.
  48. *
  49. * <p>
  50. * Schema languages not listed here are expected to
  51. * introduce their own URIs to represent themselves.
  52. * The {@link SchemaFactory} class is capable of locating other
  53. * implementations for other schema languages at run-time.
  54. *
  55. * <p>
  56. * Note that because the XML DTD is strongly tied to the parsing process
  57. * and has a significant effect on the parsing process, it is impossible
  58. * to define the DTD validation as a process independent from parsing.
  59. * For this reason, this specification does not define the semantics for
  60. * the XML DTD. This doesn't prohibit implentors from implementing it
  61. * in a way they see fit, but <em>users are warned that any DTD
  62. * validation implemented on this interface necessarily deviate from
  63. * the XML DTD semantics as defined in the XML 1.0</em>.
  64. *
  65. * <table border="1" cellpadding="2">
  66. * <thead>
  67. * <tr>
  68. * <th>value</th>
  69. * <th>language</th>
  70. * </tr>
  71. * </thead>
  72. * <tbody>
  73. * <tr>
  74. * <td>{@link javax.xml.XMLConstants#W3C_XML_SCHEMA_NS_URI} ("<code>http://www.w3.org/2001/XMLSchema</code>")</td>
  75. * <td><a href="http://www.w3.org/TR/xmlschema-1">W3C XML Schema 1.0</a></td>
  76. * </tr>
  77. * <tr>
  78. * <td>{@link javax.xml.XMLConstants#RELAXNG_NS_URI} ("<code>http://relaxng.org/ns/structure/1.0</code>")</td>
  79. * <td><a href="http://www.relaxng.org/">RELAX NG 1.0</a></td>
  80. * </tr>
  81. * </tbody>
  82. * </table>
  83. *
  84. * @author <a href="mailto:Kohsuke.Kawaguchi@Sun.com">Kohsuke Kawaguchi</a>
  85. * @version $Revision: 1.20.10.1.2.2 $, $Date: 2004/06/11 14:59:49 $
  86. * @since 1.5
  87. */
  88. public abstract class SchemaFactory {
  89. /**
  90. * <p>Constructor for derived classes.</p>
  91. *
  92. * <p>The constructor does nothing.</p>
  93. *
  94. * <p>Derived classes must create {@link SchemaFactory} objects that have
  95. * <code>null</code> {@link ErrorHandler} and
  96. * <code>null</code> {@link LSResourceResolver}.</p>
  97. */
  98. protected SchemaFactory() {
  99. }
  100. /**
  101. * <p>Lookup an implementation of the <code>SchemaFactory</code> that supports the specified
  102. * schema language and return it.</p>
  103. *
  104. * <p>To find a <code>SchemaFactory</code> object for a given schema language,
  105. * this method looks the following places in the following order
  106. * where "the class loader" refers to the context class loader:</p>
  107. * <ol>
  108. * <li>
  109. * If the system property
  110. * <code>"javax.xml.validation.SchemaFactory:<i>schemaLanguage</i>"</code>
  111. * is present (where <i>schemaLanguage</i> is the parameter
  112. * to this method), then its value is read
  113. * as a class name. The method will try to
  114. * create a new instance of this class by using the class loader,
  115. * and returns it if it is successfully created.
  116. * </li>
  117. * <li>
  118. * <code>$java.home/lib/jaxp.properties</code> is read and
  119. * the value associated with the key being the system property above
  120. * is looked for. If present, the value is processed just like above.
  121. * </li>
  122. * <li>
  123. * <p>The class loader is asked for service provider provider-configuration files matching
  124. * <code>javax.xml.validation.SchemaFactory</code> in the resource directory META-INF/services.
  125. * See the JAR File Specification for file format and parsing rules.
  126. * Each potential service provider is required to implement the method:</p>
  127. * <pre>
  128. * {@link #isSchemaLanguageSupported(String schemaLanguage)}
  129. * </pre>
  130. * The first service provider found in class loader order that supports the specified schema language is returned.
  131. * </li>
  132. * <li>
  133. * Platform default <code>SchemaFactory</code> is located
  134. * in a implementation specific way. There must be a platform default
  135. * <code>SchemaFactory</code> for W3C XML Schema.
  136. * </li>
  137. * </ol>
  138. *
  139. * <p>If everything fails, {@link IllegalArgumentException} will be thrown.</p>
  140. *
  141. * <p><strong>Tip for Trouble-shooting:</strong></p>
  142. * <p>See {@link java.util.Properties#load(java.io.InputStream)} for
  143. * exactly how a property file is parsed. In particular, colons ':'
  144. * need to be escaped in a property file, so make sure schema language
  145. * URIs are properly escaped in it. For example:</p>
  146. * <pre>
  147. * http\://www.w3.org/2001/XMLSchema=org.acme.foo.XSSchemaFactory
  148. * </pre>
  149. *
  150. * @param schemaLanguage
  151. * Specifies the schema language which the returned
  152. * SchemaFactory will understand. See
  153. * <a href="#schemaLanguage">the list of available
  154. * schema languages</a> for the possible values.
  155. *
  156. * @return New instance of a <code>SchemaFactory</code>
  157. *
  158. * @throws IllegalArgumentException
  159. * If no implementation of the schema language is available.
  160. *
  161. * @throws NullPointerException
  162. * If the <tt>schemLanguage</tt> parameter is null.
  163. */
  164. public static final SchemaFactory newInstance(String schemaLanguage) {
  165. ClassLoader cl;
  166. try {
  167. // prior to JDK1.2, this will throw NoSuchMethodError.
  168. cl = Thread.currentThread().getContextClassLoader();
  169. } catch (Throwable t) {
  170. cl = null;
  171. }
  172. if (cl == null) {
  173. cl = ClassLoader.getSystemClassLoader();
  174. }
  175. SchemaFactory f = new SchemaFactoryFinder(cl).newFactory(schemaLanguage);
  176. if (f == null) {
  177. throw new IllegalArgumentException(schemaLanguage);
  178. }
  179. return f;
  180. }
  181. /**
  182. * <p>Is specified schema supported by this <code>SchemaFactory</code>?</p>
  183. *
  184. * @param schemaLanguage Specifies the schema language which the returned <code>SchemaFactory</code> will understand.
  185. * <code>schemaLanguage</code> must specify a <a href="#schemaLanguage">valid</a> schema language.
  186. *
  187. * @return <code>true</code> if <code>SchemaFactory</code> supports <code>schemaLanguage</code>, else <code>false</code>.
  188. *
  189. * @throws NullPointerException If <code>schemaLanguage</code> is <code>null</code>.
  190. * @throws IllegalArgumentException If <code>schemaLanguage.length() == 0</code>
  191. * or <code>schemaLanguage</code> does not specify a <a href="#schemaLanguage">valid</a> schema language.
  192. */
  193. public abstract boolean isSchemaLanguageSupported(String schemaLanguage);
  194. /**
  195. * Look up the value of a feature flag.
  196. *
  197. * <p>The feature name is any fully-qualified URI. It is
  198. * possible for a {@link SchemaFactory} to recognize a feature name but
  199. * temporarily be unable to return its value.
  200. *
  201. * <p>Implementors are free (and encouraged) to invent their own features,
  202. * using names built on their own URIs.</p>
  203. *
  204. * @param name The feature name, which is a non-null fully-qualified URI.
  205. * @return The current value of the feature (true or false).
  206. * @exception org.xml.sax.SAXNotRecognizedException If the feature
  207. * value can't be assigned or retrieved.
  208. * @exception org.xml.sax.SAXNotSupportedException When the
  209. * {@link SchemaFactory} recognizes the feature name but
  210. * cannot determine its value at this time.
  211. * @exception NullPointerException
  212. * if the name parameter is null.
  213. * @see #setFeature(String, boolean)
  214. */
  215. public boolean getFeature(String name) throws SAXNotRecognizedException, SAXNotSupportedException {
  216. if (name == null) {
  217. throw new NullPointerException("the name parameter is null");
  218. }
  219. throw new SAXNotRecognizedException(name);
  220. }
  221. /**
  222. * Set the value of a feature flag.
  223. *
  224. * <p>
  225. * Feature can be used to control the way a {@link SchemaFactory}
  226. * parses schemas, although {@link SchemaFactory}s are not required
  227. * to recognize any specific feature names.</p>
  228. *
  229. * <p>The feature name is any fully-qualified URI. It is
  230. * possible for a {@link SchemaFactory} to expose a feature value but
  231. * to be unable to change the current value.</p>
  232. *
  233. * <p>All implementations are required to support the {@link javax.xml.XMLConstants#FEATURE_SECURE_PROCESSING} feature.
  234. * When the feature is:</p>
  235. * <ul>
  236. * <li>
  237. * <code>true</code>: the implementation will limit XML processing to conform to implementation limits.
  238. * Examples include enity expansion limits and XML Schema constructs that would consume large amounts of resources.
  239. * If XML processing is limited for security reasons, it will be reported via a call to the registered
  240. * {@link ErrorHandler#fatalError(SAXParseException exception)}.
  241. * See {@link #setErrorHandler(ErrorHandler errorHandler)}.
  242. * </li>
  243. * <li>
  244. * <code>false</code>: the implementation will processing XML according to the XML specifications without
  245. * regard to possible implementation limits.
  246. * </li>
  247. * </ul>
  248. *
  249. * @param name The feature name, which is a non-null fully-qualified URI.
  250. * @param value The requested value of the feature (true or false).
  251. *
  252. * @exception org.xml.sax.SAXNotRecognizedException If the feature
  253. * value can't be assigned or retrieved.
  254. * @exception org.xml.sax.SAXNotSupportedException When the
  255. * {@link SchemaFactory} recognizes the feature name but
  256. * cannot set the requested value.
  257. * @exception NullPointerException
  258. * if the name parameter is null.
  259. *
  260. * @see #getFeature(String)
  261. */
  262. public void setFeature(String name, boolean value) throws SAXNotRecognizedException, SAXNotSupportedException {
  263. if (name == null) {
  264. throw new NullPointerException("the name parameter is null");
  265. }
  266. throw new SAXNotRecognizedException(name);
  267. }
  268. /**
  269. * Set the value of a property.
  270. *
  271. * <p>The property name is any fully-qualified URI. It is
  272. * possible for a {@link SchemaFactory} to recognize a property name but
  273. * to be unable to change the current value.</p>
  274. *
  275. * <p>{@link SchemaFactory}s are not required to recognize setting
  276. * any specific property names.</p>
  277. *
  278. * @param name The property name, which is a non-null fully-qualified URI.
  279. * @param object The requested value for the property.
  280. * @exception org.xml.sax.SAXNotRecognizedException If the property
  281. * value can't be assigned or retrieved.
  282. * @exception org.xml.sax.SAXNotSupportedException When the
  283. * {@link SchemaFactory} recognizes the property name but
  284. * cannot set the requested value.
  285. * @exception NullPointerException
  286. * if the name parameter is null.
  287. */
  288. public void setProperty(String name, Object object) throws SAXNotRecognizedException, SAXNotSupportedException {
  289. if (name == null) {
  290. throw new NullPointerException("the name parameter is null");
  291. }
  292. throw new SAXNotRecognizedException(name);
  293. }
  294. /**
  295. * Look up the value of a property.
  296. *
  297. * <p>The property name is any fully-qualified URI. It is
  298. * possible for a {@link SchemaFactory} to recognize a property name but
  299. * temporarily be unable to return its value.</p>
  300. *
  301. * <p>{@link SchemaFactory}s are not required to recognize any specific
  302. * property names.</p>
  303. *
  304. * <p>Implementors are free (and encouraged) to invent their own properties,
  305. * using names built on their own URIs.</p>
  306. *
  307. * @param name The property name, which is a non-null fully-qualified URI.
  308. * @return The current value of the property.
  309. * @exception org.xml.sax.SAXNotRecognizedException If the property
  310. * value can't be assigned or retrieved.
  311. * @exception org.xml.sax.SAXNotSupportedException When the
  312. * XMLReader recognizes the property name but
  313. * cannot determine its value at this time.
  314. * @exception NullPointerException
  315. * if the name parameter is null.
  316. * @see #setProperty(String, Object)
  317. */
  318. public Object getProperty(String name) throws SAXNotRecognizedException, SAXNotSupportedException {
  319. if (name == null) {
  320. throw new NullPointerException("the name parameter is null");
  321. }
  322. throw new SAXNotRecognizedException(name);
  323. }
  324. /**
  325. * Sets the {@link ErrorHandler} to receive errors encountered
  326. * during the <code>newSchema</code> method invocation.
  327. *
  328. * <p>
  329. * Error handler can be used to customize the error handling process
  330. * during schema parsing. When an {@link ErrorHandler} is set,
  331. * errors found during the parsing of schemas will be first sent
  332. * to the {@link ErrorHandler}.
  333. *
  334. * <p>
  335. * The error handler can abort the parsing of a schema immediately
  336. * by throwing {@link SAXException} from the handler. Or for example
  337. * it can print an error to the screen and try to continue the
  338. * processing by returning normally from the {@link ErrorHandler}
  339. *
  340. * <p>
  341. * If any {@link Throwable} (or instances of its derived classes)
  342. * is thrown from an {@link ErrorHandler},
  343. * the caller of the <code>newSchema</code> method will be thrown
  344. * the same {@link Throwable} object.
  345. *
  346. * <p>
  347. * {@link SchemaFactory} is not allowed to
  348. * throw {@link SAXException} without first reporting it to
  349. * {@link ErrorHandler}.
  350. *
  351. * <p>
  352. * Applications can call this method even during a {@link Schema}
  353. * is being parsed.
  354. *
  355. * <p>
  356. * When the {@link ErrorHandler} is null, the implementation will
  357. * behave as if the following {@link ErrorHandler} is set:
  358. * <pre>
  359. * class DraconianErrorHandler implements {@link ErrorHandler} {
  360. * public void fatalError( {@link org.xml.sax.SAXParseException} e ) throws {@link SAXException} {
  361. * throw e;
  362. * }
  363. * public void error( {@link org.xml.sax.SAXParseException} e ) throws {@link SAXException} {
  364. * throw e;
  365. * }
  366. * public void warning( {@link org.xml.sax.SAXParseException} e ) throws {@link SAXException} {
  367. * // noop
  368. * }
  369. * }
  370. * </pre>
  371. *
  372. * <p>
  373. * When a new {@link SchemaFactory} object is created, initially
  374. * this field is set to null. This field will <em>NOT</em> be
  375. * inherited to {@link Schema}s, {@link Validator}s, or
  376. * {@link ValidatorHandler}s that are created from this {@link SchemaFactory}.
  377. *
  378. *
  379. * @param errorHandler
  380. * A new error handler to be set. This parameter can be null.
  381. */
  382. public abstract void setErrorHandler(ErrorHandler errorHandler);
  383. /**
  384. * Gets the current {@link ErrorHandler} set to this {@link SchemaFactory}.
  385. *
  386. * @return
  387. * This method returns the object that was last set through
  388. * the {@link #setErrorHandler(ErrorHandler)} method, or null
  389. * if that method has never been called since this {@link SchemaFactory}
  390. * has created.
  391. *
  392. * @see #setErrorHandler(ErrorHandler)
  393. */
  394. public abstract ErrorHandler getErrorHandler();
  395. /**
  396. * Sets the {@link LSResourceResolver} to customize
  397. * resource resolution when parsing schemas.
  398. *
  399. * <p>
  400. * {@link SchemaFactory} uses a {@link LSResourceResolver}
  401. * when it needs to locate external resources while parsing schemas,
  402. * although exactly what constitutes "locating external resources" is
  403. * up to each schema language. For example, for W3C XML Schema,
  404. * this includes files <tt><include></tt>d or <tt><import></tt>ed,
  405. * and DTD referenced from schema files, etc.
  406. *
  407. * <p>
  408. * Applications can call this method even during a {@link Schema}
  409. * is being parsed.
  410. *
  411. * <p>
  412. * When the {@link LSResourceResolver} is null, the implementation will
  413. * behave as if the following {@link LSResourceResolver} is set:
  414. * <pre>
  415. * class DumbDOMResourceResolver implements {@link LSResourceResolver} {
  416. * public {@link org.w3c.dom.ls.LSInput} resolveResource(
  417. * String publicId, String systemId, String baseURI) {
  418. *
  419. * return null; // always return null
  420. * }
  421. * }
  422. * </pre>
  423. *
  424. * <p>
  425. * If a {@link LSResourceResolver} throws a {@link RuntimeException}
  426. * (or instances of its derived classes),
  427. * then the {@link SchemaFactory} will abort the parsing and
  428. * the caller of the <code>newSchema</code> method will receive
  429. * the same {@link RuntimeException}.
  430. *
  431. * <p>
  432. * When a new {@link SchemaFactory} object is created, initially
  433. * this field is set to null. This field will <em>NOT</em> be
  434. * inherited to {@link Schema}s, {@link Validator}s, or
  435. * {@link ValidatorHandler}s that are created from this {@link SchemaFactory}.
  436. *
  437. * @param resourceResolver
  438. * A new resource resolver to be set. This parameter can be null.
  439. */
  440. public abstract void setResourceResolver(LSResourceResolver resourceResolver);
  441. /**
  442. * Gets the current {@link LSResourceResolver} set to this {@link SchemaFactory}.
  443. *
  444. * @return
  445. * This method returns the object that was last set through
  446. * the {@link #setResourceResolver(LSResourceResolver)} method, or null
  447. * if that method has never been called since this {@link SchemaFactory}
  448. * has created.
  449. *
  450. * @see #setErrorHandler(ErrorHandler)
  451. */
  452. public abstract LSResourceResolver getResourceResolver();
  453. /**
  454. * <p>Parses the specified source as a schema and returns it as a schema.</p>
  455. *
  456. * <p>This is a convenience method for {@link #newSchema(Source[] schemas)}.</p>
  457. *
  458. * @param schema Source that represents a schema.
  459. *
  460. * @return New <code>Schema</code> from parsing <code>schema</code>.
  461. *
  462. * @throws SAXException If a SAX error occurs during parsing.
  463. * @throws NullPointerException if <tt>schema</tt> is null.
  464. */
  465. public Schema newSchema(Source schema) throws SAXException {
  466. return newSchema(new Source[]{schema});
  467. }
  468. /**
  469. * <p>Parses the specified <code>File</code> as a schema and returns it as a <code>Schema</code>.</p>
  470. *
  471. * <p>This is a convenience method for {@link #newSchema(Source schema)}.</p>
  472. *
  473. * @param schema File that represents a schema.
  474. *
  475. * @return New <code>Schema</code> from parsing <code>schema</code>.
  476. *
  477. * @throws SAXException If a SAX error occurs during parsing.
  478. * @throws NullPointerException if <tt>schema</tt> is null.
  479. */
  480. public Schema newSchema(File schema) throws SAXException {
  481. return newSchema(new StreamSource(schema));
  482. }
  483. /**
  484. * <p>Parses the specified <code>URL</code> as a schema and returns it as a <code>Schema</code>.</p>
  485. *
  486. * <p>This is a convenience method for {@link #newSchema(Source schema)}.</p>
  487. *
  488. * @param schema <code>URL</code> that represents a schema.
  489. *
  490. * @return New <code>Schema</code> from parsing <code>schema</code>.
  491. *
  492. * @throws SAXException If a SAX error occurs during parsing.
  493. * @throws NullPointerException if <tt>schema</tt> is null.
  494. */
  495. public Schema newSchema(URL schema) throws SAXException {
  496. return newSchema(new StreamSource(schema.toExternalForm()));
  497. }
  498. /**
  499. * Parses the specified source(s) as a schema and returns it as a schema.
  500. *
  501. * <p>
  502. * The callee will read all the {@link Source}s and combine them into a
  503. * single schema. The exact semantics of the combination depends on the schema
  504. * language that this {@link SchemaFactory} object is created for.
  505. *
  506. * <p>
  507. * When an {@link ErrorHandler} is set, the callee will report all the errors
  508. * found in sources to the handler. If the handler throws an exception, it will
  509. * abort the schema compilation and the same exception will be thrown from
  510. * this method. Also, after an error is reported to a handler, the callee is allowed
  511. * to abort the further processing by throwing it. If an error handler is not set,
  512. * the callee will throw the first error it finds in the sources.
  513. *
  514. * <h2>W3C XML Schema 1.0</h2>
  515. * <p>
  516. * The resulting schema contains components from the specified sources.
  517. * The same result would be achieved if all these sources were
  518. * imported, using appropriate values for schemaLocation and namespace,
  519. * into a single schema document with a different targetNamespace
  520. * and no components of its own, if the import elements were given
  521. * in the same order as the sources. Section 4.2.3 of the XML Schema
  522. * recommendation describes the options processors have in this
  523. * regard. While a processor should be consistent in its treatment of
  524. * JAXP schema sources and XML Schema imports, the behaviour between
  525. * JAXP-compliant parsers may vary; in particular, parsers may choose
  526. * to ignore all but the first <import> for a given namespace,
  527. * regardless of information provided in schemaLocation.
  528. *
  529. * <p>
  530. * If the parsed set of schemas includes error(s) as
  531. * specified in the section 5.1 of the XML Schema spec, then
  532. * the error must be reported to the {@link ErrorHandler}.
  533. *
  534. * <h2>RELAX NG</h2>
  535. *
  536. * <p>For RELAX NG, this method must throw {@link UnsupportedOperationException}
  537. * if <tt>schemas.length!=1</tt>.
  538. *
  539. *
  540. * @param schemas
  541. * inputs to be parsed. {@link SchemaFactory} is required
  542. * to recognize {@link javax.xml.transform.sax.SAXSource},
  543. * {@link StreamSource}, and {@link javax.xml.transform.dom.DOMSource}.
  544. *
  545. * @return
  546. * Always return a non-null valid {@link Schema} object.
  547. * Note that when an error has been reported, there is no
  548. * guarantee that the returned {@link Schema} object is
  549. * meaningful.
  550. *
  551. * @throws SAXException
  552. * If an error is found during processing the specified inputs.
  553. * When an {@link ErrorHandler} is set, errors are reported to
  554. * there first. See {@link #setErrorHandler(ErrorHandler)}.
  555. * @throws NullPointerException
  556. * If the <code>schemas</code> parameter itself is null or
  557. * any item in the array is null.
  558. * @throws IllegalArgumentException
  559. * If any item in the array is not recognized by this method.
  560. * @throws UnsupportedOperationException
  561. * If the schema language doesn't support this operation.
  562. */
  563. public abstract Schema newSchema(Source[] schemas) throws SAXException;
  564. /**
  565. * Creates a special {@link Schema} object.
  566. *
  567. * <p>
  568. * The exact semantics of the returned {@link Schema} object depends
  569. * on the schema language that this {@link SchemaFactory} is created
  570. * for.
  571. *
  572. * <p>
  573. * Also, implementations are allowed to use implementation-specific
  574. * property/feature to alter the semantics of this method.
  575. *
  576. *
  577. * <h2>W3C XML Schema 1.0</h2>
  578. * <p>
  579. * For XML Schema, this method creates a {@link Schema} object that
  580. * performs validation by using location hints specified in documents.
  581. *
  582. * <p>
  583. * The returned {@link Schema} object assumes that if documents
  584. * refer to the same URL in the schema location hints,
  585. * they will always resolve to the same schema document. This
  586. * asusmption allows implementations to reuse parsed results of
  587. * schema documents so that multiple validations against the same
  588. * schema will run faster.
  589. *
  590. * <p>
  591. * Note that the use of schema location hints introduces a
  592. * vulnerability to denial-of-service attacks.
  593. *
  594. *
  595. * <h2>RELAX NG</h2>
  596. * <p>
  597. * RELAX NG does not support this operation.
  598. *
  599. * @return
  600. * Always return non-null valid {@link Schema} object.
  601. *
  602. * @throws UnsupportedOperationException
  603. * If this operation is not supported by the callee.
  604. * @throws SAXException
  605. * If this operation is supported but failed for some reason.
  606. */
  607. public abstract Schema newSchema() throws SAXException;
  608. }