Debian Codegraph @

net/sf/saxon/s9api/SchemaManager.java

raw symbols SCIP
1 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2 // Copyright (c) 2018 Saxonica Limited.
3 // This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
4 // If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
5 // This Source Code Form is "Incompatible With Secondary Licenses", as defined by the Mozilla Public License, v. 2.0.
6 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
7
8 package net.sf.saxon.s9api;
9
10 import net.sf.saxon.lib.SchemaURIResolver;
11
12 import javax.xml.transform.ErrorListener;
13 import javax.xml.transform.Source;
14
15 /**
16 * The SchemaManager is used to load schema documents, and to set options for the way in which they are loaded.
17 * At present all the resulting schema components are held in a single pool owned by the Processor object.
18 * <p>To obtain a <code>SchemaManager</code>, use the method {@link net.sf.saxon.s9api.Processor#getSchemaManager()}.</p>
19 * <p>In a schema-aware Processor there is exactly one
20 * <code>SchemaManager</code> (in a non-schema-aware Processor there is none).</p>
21 * <p>The cache of compiled schema definitions can include only one schema
22 * component (for example a type, or an element declaration) with any given name.
23 * An attempt to compile two different schemas in the same namespace will usually
24 * therefore fail.</p>
25 * <p>As soon as a type definition or element declaration is used for the first
26 * time in a validation episode, it is marked as being "sealed": this prevents subsequent
27 * modifications to the component. Examples of modifications that are thereby disallowed
28 * include adding to the substitution group of an existing element declaration, adding subtypes
29 * to an existing type, or redefining components using &lt;xs:redefine&gt;</p>
30 */
31 public abstract class SchemaManager {
32
33 public SchemaManager() {
34 }
35
36 ;
37
38
39 /**
40 * Set the version of XSD in use. The value must be "1.0" or "1.1". The default is currently "1.0",
41 * but this may change in a future release.
42 *
43 * @param version the version of the XSD specification/language: either "1.0" or "1.1".
44 */
45
46 public abstract void setXsdVersion(String version);
47
48 /**
49 * Get the version of XSD in use. The value will be "1.0" or "1.1"
50 *
51 * @return the version of XSD in use.
52 */
53
54 public abstract String getXsdVersion();
55
56 /**
57 * Set the ErrorListener to be used while loading and validating schema documents
58 *
59 * @param listener The error listener to be used. This is notified of all errors detected during the
60 * compilation. May be set to null to revert to the default ErrorListener.
61 */
62
63 public abstract void setErrorListener(/*@Nullable*/ ErrorListener listener);
64
65 /**
66 * Get the ErrorListener being used while loading and validating schema documents
67 *
68 * @return listener The error listener in use. This is notified of all errors detected during the
69 * compilation. Returns null if no user-supplied ErrorListener has been set.
70 */
71
72 /*@Nullable*/
73 public abstract ErrorListener getErrorListener();
74
75 /**
76 * Set the SchemaURIResolver to be used during schema loading. This SchemaURIResolver, despite its name,
77 * is <b>not</b> used for resolving relative URIs against a base URI; it is used for dereferencing
78 * an absolute URI (after resolution) to return a {@link javax.xml.transform.Source} representing the
79 * location where a schema document can be found.
80 * <p>This SchemaURIResolver is used to dereference the URIs appearing in <code>xs:import</code>,
81 * <code>xs:include</code>, and <code>xs:redefine</code> declarations.</p>
82 *
83 * @param resolver the SchemaURIResolver to be used during schema loading.
84 */
85
86 public abstract void setSchemaURIResolver(SchemaURIResolver resolver);
87
88 /**
89 * Get the SchemaURIResolver to be used during schema loading.
90 *
91 * @return the URIResolver used during stylesheet compilation. Returns null if no user-supplied
92 * URIResolver has been set.
93 */
94
95 public abstract SchemaURIResolver getSchemaURIResolver();
96
97 /**
98 * Load a schema document from a given Source. The schema components derived from this schema
99 * document are added to the cache of schema components maintained by this SchemaManager
100 *
101 * @param source the document containing the schema. The getSystemId() method applied to this Source
102 * must return a base URI suitable for resolving <code>xs:include</code> and <code>xs:import</code>
103 * directives. The document may be either a schema document in source XSD format, or a compiled
104 * schema in Saxon-defined SCM format (as produced using the -export option)
105 * @throws SaxonApiException if the schema document is not valid, or if its contents are inconsistent
106 * with the schema components already held by this SchemaManager.
107 */
108
109 public abstract void load(Source source) throws SaxonApiException;
110
111 /**
112 * Import a precompiled Schema Component Model from a given Source. The schema components derived from this schema
113 * document are added to the cache of schema components maintained by this SchemaManager
114 *
115 * @param source the XML file containing the schema component model, as generated by a previous call on
116 * {@link #exportComponents}
117 * @throws SaxonApiException if a failure occurs loading the schema from the supplied source
118 */
119
120 public abstract void importComponents(Source source) throws SaxonApiException;
121
122 /**
123 * Export a precompiled Schema Component Model containing all the components (except built-in components)
124 * that have been loaded into this Processor.
125 *
126 * @param destination the destination to recieve the precompiled Schema Component Model in the form of an
127 * XML document
128 * @throws SaxonApiException if a failure occurs writing the schema components to the supplied destination
129 */
130
131 public abstract void exportComponents(Destination destination) throws SaxonApiException;
132
133 /**
134 * Create a SchemaValidator which can be used to validate instance documents against the schema held by this
135 * SchemaManager
136 *
137 * @return a new SchemaValidator
138 */
139
140 public abstract SchemaValidator newSchemaValidator();
141
142
143 }
144