1 package dbms_xmlschema authid current_user is
2 ---------------------------------------------
3 -- OVERVIEW
4 --
5 -- This package provides procedures to
6 -- (*) register an XML schema
7 -- (*) delete a previously registered XML schema
8 -- (*) re-compile a previously registered XML schema
9 -- (*) generate an XML schema
10 --
11 ---------------------------------------------
12
13 ------------
14 -- CONSTANTS
15 --
16 ------------
17 DELETE_RESTRICT CONSTANT NUMBER := 1;
18 DELETE_INVALIDATE CONSTANT NUMBER := 2;
19 DELETE_CASCADE CONSTANT NUMBER := 3;
20 DELETE_CASCADE_FORCE CONSTANT NUMBER := 4;
21 DELETE_MIGRATE CONSTANT NUMBER := 8;
22
23 ENABLE_HIERARCHY_NONE CONSTANT PLS_INTEGER := 1;
24 ENABLE_HIERARCHY_CONTENTS CONSTANT PLS_INTEGER := 2;
25 ENABLE_HIERARCHY_RESMETADATA CONSTANT PLS_INTEGER := 3;
26 ENABLE_HIERARCHY_VERSION CONSTANT PLS_INTEGER := 4;
27 ENABLE_HIERARCHY_LINKS CONSTANT PLS_INTEGER := 8;
28
29 REGISTER_NODOCID CONSTANT NUMBER := 1;
30 REGISTER_BINARYXML CONSTANT NUMBER := 2;
31 REGISTER_NT_AS_IOT CONSTANT NUMBER := 4;
32
33 REGISTER_CSID_NULL CONSTANT NUMBER := -1;
34
35 COPYEVOLVE_BINARY_XML CONSTANT NUMBER := 1;
36
37 INPLACE_EVOLVE CONSTANT NUMBER := 1;
38 INPLACE_TRACE CONSTANT NUMBER := 2;
39
40 PRESERVE_PROP_NUMBERS CONSTANT NUMBER := 1;
41
42 ------------
43 -- TYPES
44 ------------
45 TYPE URLARR is VARRAY(1000) of VARCHAR2(1000);
46 TYPE XMLARR is VARRAY(1000) of XMLType;
47 TYPE UNAME_ARR is VARRAY(1000) of VARCHAR2(100);
48
49 ---------------------------------------------
50 -- PROCEDURE - registerSchema
51 -- PARAMETERS -
52 -- schemaURL
53 -- A name that uniquely identifies the schema document.
54 -- schemaDoc
55 -- a valid XML schema document
56 -- local
57 -- Is this a local or global schema ? By default, all schemas
58 -- are registered as local schemas i.e. under
59 -- /sys/schemas/<username>/...
60 -- If a schema is registered as global, it is added under
61 -- /sys/schemas/PUBLIC/...
62 -- You need write privileges on the above directory to be
63 -- able to register a schema as global.
64 -- genTypes
65 -- Should the schema compiler generate object types ?
66 -- genbean
67 -- Should the schema compiler generate Java beans ?
68 -- genTables
69 -- Should the schema compiler generate default tables ?
70 -- force
71 -- Should the schema be created/stored even with errors?
72 -- Setting this to TRUE will register the schema in the
73 -- hierarchy even if there were compilation errors, but
74 -- the schema cannot be used until it is made valid.
75 -- csid
76 -- Character set id of the input blob or bfile.
77 -- The value REGISTER_CSID_NULL indicates that the CSID was
78 -- not passed in. If users pass in REGISTER_CSID_NULL as the value
79 -- of the csid parameter, then the behavior will be the same as
80 -- when csid was not passed in.
81 -- options
82 -- Additional options to specify how the schema should be
83 -- registered. The various options are represented as bits
84 -- of an integer and the options parameter should be
85 -- constructed by doing a bitor of the desired bits.
86 -- The possible bits for this are:
87 -- REGISTER_NODOCID :: this will suppress the creation
88 -- of the DOCID column for out of line tables. This is a
89 -- storage optimization which might be desirable when
90 -- we do not need to join back to the document table (for example
91 -- if we do not care about rewriting certain queries that could
92 -- be rewritten by making use of the DOCID column)
93 -- REGISTER_BINARYXML :: this scema is used for CSX
94 -- REGISTER_NT_AS_IOT :: this will store the
95 -- nested tables as IOTs instead of heap (which is the default storage)
96 -- enableHierarchy
97 -- Specifies how the tables generated during schema registration
98 -- should be hierarchically enabled. It must be one of the following:
99 -- ENABLE_HIERARCHY_NONE : none of the tables will have hierarchy
100 -- enabled on them
101 -- ENABLE_HIERARCHY_CONTENTS : enables hierarchy for contents i.e.
102 -- the tables can be used to store contents of resources
103 -- ENABLE_HIERARCHY_RESMETADATA : enables hierarchy for resource metadata
104 -- i.e. the tables can be used to store resource metadata
105 -- ENABLE_HIERARCHY_VERSION : version-enable all table created during
106 -- registration. Must be combined with either ENABLE_HIERARCHY_CONTENTS
107 -- or ENABLE_HIERARCHY_RESMETADATA.
108 -- ENABLE_HIERARCHY_LINKS : enable hierarchy and enable link processing on
109 -- the table. Must be combined with ENABLE_HIERARCHY_CONTENTS
110 --
111 -- EXCEPTIONS
112 -- ORA-31001: Invalid resource handle or path name
113 -- todo
114 ---------------------------------------------
115 procedure registerSchema(schemaURL IN varchar2,
116 schemaDoc IN VARCHAR2,
117 local IN BOOLEAN := TRUE,
118 genTypes IN BOOLEAN := TRUE,
119 genbean IN BOOLEAN := FALSE,
120 genTables IN BOOLEAN := TRUE,
121 force IN BOOLEAN := FALSE,
122 owner IN VARCHAR2 := '',
123 enableHierarchy IN pls_integer :=
124 ENABLE_HIERARCHY_CONTENTS,
125 options IN pls_integer := 0);
126
127 procedure registerSchema(schemaURL IN varchar2,
128 schemaDoc IN CLOB,
129 local IN BOOLEAN := TRUE,
130 genTypes IN BOOLEAN := TRUE,
131 genbean IN BOOLEAN := FALSE,
132 genTables IN BOOLEAN := TRUE,
133 force IN BOOLEAN := FALSE,
134 owner IN VARCHAR2 := '',
135 enableHierarchy IN pls_integer :=
136 ENABLE_HIERARCHY_CONTENTS,
137 options IN pls_integer := 0,
138 schemaoid IN RAW := NULL,
139 import_options IN pls_integer := 0);
140
141 procedure registerSchema(schemaURL IN varchar2,
142 schemaDoc IN BLOB,
143 local IN BOOLEAN := TRUE,
144 genTypes IN BOOLEAN := TRUE,
145 genbean IN BOOLEAN := FALSE,
146 genTables IN BOOLEAN := TRUE,
147 force IN BOOLEAN := FALSE,
148 owner IN VARCHAR2 := '',
149 csid IN NUMBER := REGISTER_CSID_NULL,
150 enableHierarchy IN pls_integer :=
151 ENABLE_HIERARCHY_CONTENTS,
152 options IN pls_integer := 0);
153
154 procedure registerSchema(schemaURL IN varchar2,
155 schemaDoc IN BFILE,
156 local IN BOOLEAN := TRUE,
157 genTypes IN BOOLEAN := TRUE,
158 genbean IN BOOLEAN := FALSE,
159 genTables IN BOOLEAN := TRUE,
160 force IN BOOLEAN := FALSE,
161 owner IN VARCHAR2 := '',
162 csid IN NUMBER := REGISTER_CSID_NULL,
163 enableHierarchy IN pls_integer :=
164 ENABLE_HIERARCHY_CONTENTS,
165 options IN pls_integer := 0);
166
167 procedure registerSchema(schemaURL IN varchar2,
168 schemaDoc IN sys.XMLType,
169 local IN BOOLEAN := TRUE,
170 genTypes IN BOOLEAN := TRUE,
171 genbean IN BOOLEAN := FALSE,
172 genTables IN BOOLEAN := TRUE,
173 force IN BOOLEAN := FALSE,
174 owner IN VARCHAR2 := '',
175 enableHierarchy IN pls_integer :=
176 ENABLE_HIERARCHY_CONTENTS,
177 options IN pls_integer := 0);
178
179 procedure registerSchema(schemaURL IN varchar2,
180 schemaDoc IN sys.UriType,
181 local IN BOOLEAN := TRUE,
182 genTypes IN BOOLEAN := TRUE,
183 genbean IN BOOLEAN := FALSE,
184 genTables IN BOOLEAN := TRUE,
185 force IN BOOLEAN := FALSE,
186 owner IN VARCHAR2 := '',
187 enableHierarchy IN pls_integer :=
188 ENABLE_HIERARCHY_CONTENTS,
189 options IN pls_integer := 0);
190
191 ---------------------------------------------
192 -- PROCEDURE - registerURI
193 -- PARAMETERS -
194 -- schemaURL
195 -- A name that uniquely identifies the schema document.
196 -- schemaDocURI
197 -- A pathname (URI) corresponding to the physical location of the
198 -- schema document. The URI path could be based on HTTP, FTP, DB or XDB
199 -- protocols. This function constructs a URIType instance using
200 -- the URIFactory - and invokes the regiserSchema function above.
201 -- <all other paramaters> Same as above
202 ---------------------------------------------
203 procedure registerURI(schemaURL IN varchar2,
204 schemaDocURI IN varchar2,
205 local IN BOOLEAN := TRUE,
206 genTypes IN BOOLEAN := TRUE,
207 genbean IN BOOLEAN := FALSE,
208 genTables IN BOOLEAN := TRUE,
209 force IN BOOLEAN := FALSE,
210 owner IN VARCHAR2 := '',
211 enableHierarchy IN pls_integer :=
212 ENABLE_HIERARCHY_CONTENTS,
213 options IN pls_integer := 0);
214
215 ---------------------------------------------
216 -- PROCEDURE - deleteSchema
217 -- PARAMETERS -
218 -- schemaURL : Name identifying the schema to be deleted
219 -- option : one of the following
220 -- DELETE_RESTRICT ::
221 -- Schema deletion fails if there are any tables or schemas that
222 -- depend on this schema.
223 -- DELETE_INVALIDATE :
224 -- Schema deletion does not fail if there are any dependencies.
225 -- Instead, it simply invalidates all dependent objects.
226 -- DELETE_CASCADE ::
227 -- Schema deletion will also drop all default SQL types and
228 -- default tables. However the deletion fails if there are
229 -- any stored instances conforming to this schema.
230 -- DELETE_CASCADE_FORCE ::
231 -- Similar to CASCADE except that it does not check for any stored
232 -- instances conforming to this schema. Also it ignores any errors.
233 -- DELETE_MIGRATE
234 -- This delete is happening during migrate mode.
235 --
236 -- EXCEPTIONS
237 -- ORA-31001: Invalid resource handle or path name
238 -- todo
239 ---------------------------------------------
240 procedure deleteSchema(schemaURL IN varchar2,
241 delete_option IN pls_integer := DELETE_RESTRICT);
242 PRAGMA SUPPLEMENTAL_LOG_DATA(deleteSchema, AUTO_WITH_COMMIT);
243
244 ---------------------------------------------
245 -- PROCEDURE - purgeSchema
246 -- Purges a schema that was previously marked delete with hide mode
247 -- PARAMETERS -
248 -- schemaURL : Name identifying the schema to be purge
249 --
250 -- EXCEPTIONS
251 -- ORA-31001: Invalid resource handle or path name
252 -- todo
253 ---------------------------------------------
254 procedure purgeSchema(schema_id IN raw);
255 PRAGMA SUPPLEMENTAL_LOG_DATA(purgeSchema, AUTO_WITH_COMMIT);
256
257 ---------------------------------------------
258 -- PROCEDURE - generateBean
259 -- This procedure can be used to generate the Java bean code
260 -- corresponding to a registered XML schema.
261 -- Note that there is also an option to generate the beans
262 -- as part of the registration procedure itself.
263 -- PARAMETERS -
264 -- schemaURL : Name identifying a registered XML schema.
265 -- EXCEPTIONS
266 -- ORA-31001: Invalid resource handle or path name
267 -- todo
268 ---------------------------------------------
269 procedure generateBean(schemaURL IN varchar2);
270 PRAGMA SUPPLEMENTAL_LOG_DATA(generateBean, AUTO_WITH_COMMIT);
271
272 ---------------------------------------------
273 -- PROCEDURE - compileSchema
274 -- This procedure can be used to re-compile an already registered XML
275 -- schema. This is useful for bringing a schema in an invalid
276 -- state to a valid state.
277 -- PARAMETERS -
278 -- schemaURL : URL identifying the schema
279 -- EXCEPTIONS
280 -- ORA-31001: Invalid resource handle or path name
281 ---------------------------------------------
282 procedure compileSchema(schemaURL IN varchar2);
283 PRAGMA SUPPLEMENTAL_LOG_DATA(compileSchema, AUTO_WITH_COMMIT);
284
285 ---------------------------------------------
286 -- FUNCTION - generateSchema(s)
287 -- These functions generate XML schema(s) from
288 -- an oracle type name. generateSchemas returns a collection
289 -- of XMLTypes, one XMLSchema document for each database schema.
290 -- generateSchema inlines them all in one schema (XMLType).
291 -- PARAMETERS -
292 -- schemaName : the name of the database schema containing the type
293 -- typeName : the name of the oracle type
294 -- elementName : the name of the toplevel element in the XMLSchema
295 -- defaults to typeName
296 -- schemaURL : specifies base URL where schemas will be stored,
297 -- needed by top level schema for import statement
298 -- recurse : whether or not to also generate schema for all types
299 -- referred to by the type specified
300 -- annotate : whether or not to put the SQL annotations in the XMLSchema
301 -- embedColl : whether you want collections embedded in the type which
302 -- refers to them or you want them to have a complexType
303 -- created, can not be false with annotations true
304 -- EXCEPTIONS
305 -- TBD
306 ---------------------------------------------
307 function generateSchemas( schemaName IN varchar2, typeName IN varchar2,
308 elementName IN varchar2 := NULL,
309 schemaURL IN varchar2 := NULL,
310 annotate IN BOOLEAN := TRUE,
311 embedColl IN BOOLEAN := TRUE )
312 return sys.XMLSequenceType;
313
314 function generateSchema( schemaName IN varchar2, typeName IN varchar2,
315 elementName IN varchar2 := NULL,
316 recurse IN BOOLEAN := TRUE,
317 annotate IN BOOLEAN := TRUE,
318 embedColl IN BOOLEAN := TRUE ) return sys.XMLType;
319
320 procedure CopyEvolve(schemaURLs IN XDB$STRING_LIST_T,
321 newSchemas IN XMLSequenceType,
322 transforms IN XMLSequenceType := NULL,
323 preserveOldDocs IN BOOLEAN := FALSE,
324 mapTabName IN VARCHAR2 := NULL,
325 generateTables IN BOOLEAN := TRUE,
326 force IN BOOLEAN := FALSE,
327 schemaOwners IN XDB$STRING_LIST_T := NULL,
328 parallelDegree IN PLS_INTEGER := 0,
329 options IN PLS_INTEGER := 0);
330 PRAGMA SUPPLEMENTAL_LOG_DATA(CopyEvolve, UNSUPPORTED_WITH_COMMIT);
331
332
333 procedure InPlaceEvolve(schemaURL IN VARCHAR2,
334 diffXML IN SYS.XMLTYPE,
335 flags IN NUMBER := 1);
336 PRAGMA SUPPLEMENTAL_LOG_DATA(InPlaceEvolve, AUTO_WITH_COMMIT);
337
338 ---------------------------------------------
339 -- FUNCTION - convertToDate
340 -- This function converts the string representation of the following
344 -- strval : string representation of valid value (per XML Schema)
341 -- specified XML Schema types into the Oracle DATE representation
342 -- using a default reference date and format mask.
343 -- PARAMETERS -
345 -- xmltypename : Name of the XML Schema datatype.
346 -- Has to be one of the following:
347 -- * gDay
348 -- * gMonth
349 -- * gYear
350 -- * gYearMonth
351 -- * gMonthDay
352 -- * date
353 ---------------------------------------------
354 function convertToDate(strval varchar2, xmltypename varchar2)
355 return DATE deterministic parallel_enable;
356
357 ---------------------------------------------
358 -- FUNCTION - convertToTS
359 -- This function converts the string representation of the following
360 -- specified XML Schema types into the Oracle TIMESTAMP representation
361 -- using a default reference date and format mask.
362 -- PARAMETERS -
363 -- strval : string representation of valid value (per XML Schema)
364 -- xmltypename : Name of the XML Schema datatype.
365 -- Has to be one of the following:
366 -- * dateTime
367 -- * time
368 ---------------------------------------------
369 function convertToTS(strval varchar2, xmltypename varchar2)
370 return TIMESTAMP deterministic parallel_enable;
371
372 ---------------------------------------------
373 -- FUNCTION - convertToTSWithTZ
374 -- This function converts the string representation of the following
375 -- specified XML Schema types into the Oracle
376 -- TIMESTAMP WITH TIMEZONE representation using a default reference
377 -- date and format mask.
378 -- PARAMETERS -
379 -- strval : string representation of valid value (per XML Schema)
380 -- xmltypename : Name of the XML Schema datatype.
381 -- Has to be one of the following:
382 -- * gDay
383 -- * gMonth
384 -- * gYear
385 -- * gYearMonth
386 -- * gMonthDay
387 -- * date
388 -- * dateTime
389 -- * time
390 ---------------------------------------------
391 function convertToTSWithTZ(strval varchar2, xmltypename varchar2)
392 return TIMESTAMP WITH TIME ZONE deterministic parallel_enable;
393
394 end dbms_xmlschema;