Rem Rem $Header: sdogmlsc.sql 12-may-2005.10:37:42 sravada Exp $ Rem Rem sdogmlsc.sql Rem Rem Copyright (c) 2005, Oracle. All rights reserved. Rem Rem NAME Rem sdogmlsc.sql - Rem Rem DESCRIPTION Rem This file is used to register the 3 schemas required for GML 212 Rem Rem NOTES Rem Rem Rem MODIFIED (MM/DD/YY) Rem sravada 05/12/05 - sravada_sdo_text_object Rem sravada 05/03/05 - Created Rem declare begin begin execute immediate 'CREATE TABLE SDO_XML_SCHEMAS ( id NUMBER PRIMARY KEY, description VARCHAR2(300), xmlSchema CLOB) '; exception when others then NULL; end; end; / GRANT SELECT ON SDO_XML_SCHEMAS TO PUBLIC; create or replace public synonym SDO_XML_SCHEMAS for MDSYS.SDO_XML_SCHEMAS; -- first delete all the GML related schemas declare usr varchar2(30); url varchar2(200); loc clob; cnt number; begin usr := 'MDSYS'; url := 'http://www.opengis.net/cartographicText.xsd'; execute immediate 'SELECT count(*) FROM dba_xml_schemas WHERE owner=:1 AND schema_url=:2' into cnt using usr, url; if cnt <> 0 then dbms_xmlschema.deleteSchema(url, dbms_xmlschema.DELETE_CASCADE); end if; url := 'http://www.opengis.net/gml/feature.xsd'; execute immediate 'SELECT count(*) FROM dba_xml_schemas WHERE owner=:1 AND schema_url=:2' into cnt using usr, url; if cnt <> 0 then dbms_xmlschema.deleteSchema(url, dbms_xmlschema.DELETE_CASCADE); end if; url := 'http://www.opengis.net/gml/geometry.xsd'; execute immediate 'SELECT count(*) FROM dba_xml_schemas WHERE owner=:1 AND schema_url=:2' into cnt using usr, url; if cnt <> 0 then dbms_xmlschema.deleteSchema(url, dbms_xmlschema.DELETE_CASCADE); end if; url := 'http://www.w3.org/1999/xlink/xlinks.xsd'; execute immediate 'SELECT count(*) FROM dba_xml_schemas WHERE owner=:1 AND schema_url=:2' into cnt using usr, url; if cnt <> 0 then dbms_xmlschema.deleteSchema(url, dbms_xmlschema.DELETE_CASCADE); end if; end; / -- register the schema DECLARE schemaclob CLOB; amt NUMBER; buf VARCHAR2(32767); pos NUMBER; BEGIN DELETE FROM SDO_XML_SCHEMAS WHERE id=1; INSERT INTO SDO_XML_SCHEMAS VALUES (1, 'GML:2.1.2 xlinks.xsd', empty_clob()) RETURNING xmlSchema into schemaclob; SELECT xmlSchema into schemaclob from SDO_XML_SCHEMAS WHERE id = 1 FOR UPDATE; DBMS_LOB.OPEN(schemaclob, DBMS_LOB.LOB_READWRITE); buf := ' xlinks.xsd v2.1.2 2002-07 This schema provides the XLink attributes for general use. The show attribute is used to communicate the desired presentation of the ending resource on traversal from the starting resource; its value should be treated as follows: new - load ending resource in a new window, frame, pane, or other presentation context replace - load the resource in the same window, frame, pane, or other presentation context embed - load ending resource in place of the presentation of the starting resource other - behavior is unconstrained; examine other markup in the link for hints none - behavior is unconstrained The actuate attribute is used to communicate the desired timing of traversal from the starting resource to the ending resource; its value should be treated as follows: onLoad - traverse to the ending resource immediately on loading the starting resource onRequest - traverse from the starting resource to the ending resource only on a post-loading event triggered for this purpose other - behavior is unconstrained; examine other markup in link for hints none - behavior is unconstrained '; amt := length(buf); pos := 1; DBMS_LOB.WRITE(schemaclob, amt, pos, buf); DBMS_LOB.CLOSE(schemaclob); COMMIT; END; / SHOW ERRORS; declare usr varchar2(30); url varchar2(200); loc clob; cnt number; begin usr := 'MDSYS'; url := 'http://www.w3.org/1999/xlink/xlinks.xsd'; -- First check whether the schema has been registered already. -- If it has, de-register it. This might cause an error to be raised if -- there are dependent tables or schemas. User then needs to manually -- remove/evolve the depdendent objects and run this script again. execute immediate 'SELECT count(*) FROM dba_xml_schemas WHERE owner=:1 AND schema_url=:2' into cnt using usr, url; if cnt <> 0 then dbms_xmlschema.deleteSchema(url, dbms_xmlschema.DELETE_CASCADE); end if; select xmlSchema into loc from SDO_XML_SCHEMAS where id = 1; -- register the schema dbms_xmlschema.registerSchema(url, loc, FALSE, FALSE, FALSE, FALSE, FALSE, usr); end; / DECLARE schemaclob CLOB; amt NUMBER; buf VARCHAR2(32767); pos NUMBER; BEGIN DELETE FROM SDO_XML_SCHEMAS WHERE id=2; INSERT INTO SDO_XML_SCHEMAS VALUES (2, 'GML:2.1.2 geometry.xsd', empty_clob()) RETURNING xmlSchema into schemaclob; SELECT xmlSchema into schemaclob from SDO_XML_SCHEMAS WHERE id = 2 FOR UPDATE; DBMS_LOB.OPEN(schemaclob, DBMS_LOB.LOB_READWRITE); buf := ' geometry.xsd v2.1.2 2002-07 GML Geometry schema. Copyright (c) 2001,2002 OGC, All Rights Reserved. All geometry elements are derived from this abstract supertype; a geometry element may have an identifying attribute (gid). It may be associated with a spatial reference system. This abstract base type for geometry collections just makes the srsName attribute mandatory. These attributes can be attached to any element, thus allowing it to act as a pointer. The remoteSchema attribute allows an element that carries link attributes to indicate that the element is declared in a remote schema rather than by the schema that constrains the current document instance. An instance of this type (e.g. a geometryMember) can either enclose or point to a primitive geometry element. When serving as a simple link that references a remote geometry instance, the value of the gml:remoteSchema attribute can be used to locate a schema fragment that constrains the target instance. Restricts the geometry member to being a Point instance. Restricts the geometry member to being a LineString instance. Restricts the geometry member to being a Polygon instance. Restricts the outer or inner boundary of a polygon instance to being a LinearRing. A Point is defined by a single coordinate tuple. A LineString is defined by two or more coordinate tuples, with linear interpolation between them. A LinearRing is defined by four or more coordinate tuples, with linear interpolation between them; the first and last coordinates must be coincident. The Box structure defines an extent using a pair of coordinate tuples. A Polygon is defined by an outer boundary and zero or more inner boundaries which are in turn defined by LinearRings. A geometry collection must include one or more geometries, referenced through geometryMember elements. User-defined geometry collections that accept GML geometry classes as members must instantiate--or derive from--this type. A MultiPoint is defined by one or more Points, referenced through pointMember elements. A MultiLineString is defined by one or more LineStrings, referenced through lineStringMember elements. A MultiPolygon is defined by one or more Polygons, referenced through polygonMember elements. Represents a coordinate tuple in one, two, or three dimensions. Coordinates can be included in a single string, but there is no facility for validating string content. The value of the cs attribute is the separator for coordinate values, and the value of the ts attribute gives the tuple separator (a single space by default); the default values may be changed to reflect local usage. '; amt := length(buf); pos := 1; DBMS_LOB.WRITE(schemaclob, amt, pos, buf); DBMS_LOB.CLOSE(schemaclob); COMMIT; END; / SHOW ERRORS; declare usr varchar2(30); url varchar2(200); loc clob; cnt number; begin usr := 'MDSYS'; url := 'http://www.opengis.net/gml/geometry.xsd'; -- First check whether the schema has been registered already. -- If it has, de-register it. This might cause an error to be raised if -- there are dependent tables or schemas. User then needs to manually -- remove/evolve the depdendent objects and run this script again. execute immediate 'SELECT count(*) FROM dba_xml_schemas WHERE owner=:1 AND schema_url=:2' into cnt using usr, url; if cnt <> 0 then dbms_xmlschema.deleteSchema(url, dbms_xmlschema.DELETE_CASCADE); end if; select xmlSchema into loc from SDO_XML_SCHEMAS where id = 2; -- register the schema dbms_xmlschema.registerSchema(url, loc, FALSE, FALSE, FALSE, FALSE, FALSE, usr); end; / DECLARE schemaclob CLOB; amt NUMBER; buf VARCHAR2(32767); pos NUMBER; BEGIN DELETE FROM SDO_XML_SCHEMAS WHERE id=3; INSERT INTO SDO_XML_SCHEMAS VALUES (3, 'GML:2.1.2 feature.xsd', empty_clob()) RETURNING xmlSchema into schemaclob; SELECT xmlSchema into schemaclob from SDO_XML_SCHEMAS WHERE id = 3 FOR UPDATE; DBMS_LOB.OPEN(schemaclob, DBMS_LOB.LOB_READWRITE); buf := ' feature.xsd v2.1.2 2002-07 GML Feature schema. Copyright (c) 2002 OGC, All Rights Reserved. An abstract feature provides a set of common properties. A concrete feature type must derive from this type and specify additional properties in an application schema. A feature may optionally possess an identifying attribute (fid). This abstract base type just makes the boundedBy element mandatory for a feature collection. A feature collection contains zero or more featureMember elements. A simple geometry property encapsulates a geometry element. Alternatively, it can function as a pointer (simple-type link) that refers to a remote geometry element. An instance of this type (e.g. a featureMember) can either enclose or point to a feature (or feature collection); this type can be restricted in an application schema to allow only specified features as valid participants in the association. When serving as a simple link that references a remote feature instance, the value of the gml:remoteSchema attribute can be used to locate a schema fragment that constrains the target instance. Bounding shapes--a Box or a null element are currently allowed. Encapsulates a single point to represent position, location, or centerOf properties. Encapsulates a single polygon to represent coverage or extentOf properties. Encapsulates a single LineString to represent centerLineOf or edgeOf properties. Encapsulates a MultiPoint element to represent the following discontiguous geometric properties: multiLocation, multiPosition, multiCenterOf. Encapsulates a MultiLineString element to represent the following discontiguous geometric properties: multiEdgeOf, multiCenterLineOf. Encapsulates a MultiPolygon to represent the following discontiguous geometric properties: multiCoverage, multiExtentOf. Encapsulates a MultiGeometry element. If a bounding shape is not provided for a feature collection, explain why. Allowable values are: innapplicable - the features do not have geometry unknown - the boundingBox cannot be computed unavailable - there may be a boundingBox but it is not divulged missing - there are no features '; amt := length(buf); pos := 1; DBMS_LOB.WRITE(schemaclob, amt, pos, buf); DBMS_LOB.CLOSE(schemaclob); COMMIT; END; / SHOW ERRORS; declare usr varchar2(30); url varchar2(200); loc clob; cnt number; begin usr := 'MDSYS'; url := 'http://www.opengis.net/gml/feature.xsd'; -- First check whether the schema has been registered already. -- If it has, de-register it. This might cause an error to be raised if -- there are dependent tables or schemas. User then needs to manually -- remove/evolve the depdendent objects and run this script again. execute immediate 'SELECT count(*) FROM dba_xml_schemas WHERE owner=:1 AND schema_url=:2' into cnt using usr, url; if cnt <> 0 then dbms_xmlschema.deleteSchema(url, dbms_xmlschema.DELETE_CASCADE); end if; select xmlSchema into loc from SDO_XML_SCHEMAS where id = 3; -- register the schema dbms_xmlschema.registerSchema(url, loc, FALSE, FALSE, FALSE, FALSE, FALSE, usr); end; / commit;