
REGISTER XMLSCHEMA (Db2 command line processor)
The REGISTER XMLSCHEMA command registers an XML schema with the Db2 database manager.
- schemaLocation-URI-1
- Specifies the schema location URI of the XML schema that is to be registered. The schema location is referenced from XML instance documents or the SQL XML schema validation function. If a single XML schema references multiple schema documents, each XML schema document other than the primary document must also be registered. Each document can be registered in either the sub-document clause in the REGISTER XMLSCHEMA command or in a separate ADD XMLSCHEMA DOCUMENT command.
- FROM content-URI
- Specifies the URI where the actual content of an XML schema document is located. The Db2 command line processor supports only file URIs, which begin with file://. The XML schema document must be in the Unicode encoding scheme.
- WITH properties-URI
- Specifies the URI of a properties document that are to be associated with a schema document. The Db2 command line processor supports only file URIs, which begin with file://.
- AS relational-identifier
- Specifies a name that can be used to refer to the XML schema in relational SQL or
XML.
The schema of the relational identifier must be SYSXSR. If you specify a qualified name, the qualifier must be SYSXSR; for example, SYSXSR.MYSCHEMA. If you specify an unqualified name, you need to execute the SQL statement
SET SCHEMA="SYSXSR"
before you execute the command. A name that is enclosed in quotation marks, such as "SYSXSR.MYSCHEMA", is considered as an unqualified name. Qualifiers or schema names that are enclosed in quotation marks are not folded to uppercase. Qualifiers or schema names that are not enclosed in quotation marks are folded to uppercase. - ADD schemaLocation-URI-2
- Specifies the schema location URI of a related XML schema document, as it is referenced by this XML schema document.
- COMPLETE
- Indicates that there are no more XML schema documents to be associated with this XML schema. Validation of the schema is performed, and if there are no errors are found, the schema is to be marked as usable. Until XML schema registration is completed, the schema is not visible to or usable in other SQL or XML commands.
- WITH schema-properties-URI
- Specifies the URI of a properties document that is to be associated with this XML schema. The CLP supports only file URIs, which begin with file://. A schema properties document can be specified only when the XML schema is also being completed.
- Example: Registering and completing an XML schema with a single XML schema document
- Suppose that you want to register an XML schema named http://mycompany.com/prod/p1_1.xsd,
and to make it available immediately. The content of the XML schema is a single document that
has file URI file:///u/temp/p1_1.xsd. In SQL statements, you want to refer to the XML schema
as EXAMPLE.TEST1. Use the following command to register and complete the XML
schema.
REGISTER XMLSCHEMA http://mycompany.com/prod/p1_1.xsd FROM file:///u/temp/p1_1.xsd AS EXAMPLE.TEST1 COMPLETE
- Example: Registering and completing an XML schema with multiple XML schema documents
- Suppose that you want to register an XML schema named
http://mycompany.com/prod/cust.xsd,and to make it available immediately. The content of the
XML schema consists of three documents. The contents of the three documents are locally stored
as file:///u/temp/cust1.xsd, file:///u/temp/cust2.xsd, and file:///u/temp/cust3.xsd. The
schema location URIs for the documents are http://mycompany.com/prod/cust1.xsd,
http://mycompany.com/prod/cust2.xsd, and http://mycompany.com/prod/cust3.xsd. In SQL
statements, you want to refer to the XML schema as PRODSCHEMA. Additional properties for the
XML schema are stored in a file with file URI file:///u/temp/CUSTPROP.XML. Use following to
register and complete the XML
schema.
REGISTER XMLSCHEMA http://mycompany.com/prod/cust.xsd FROM file:///u/temp/cust.xsd' AS PRODSCHEMA WITH file:///u/temp/CUSTPROP.XML ADD http://mycompany.com/prod/cust1.xsd FROM file:///u/temp/cust1.xsd ADD http://mycompany.com/prod/cust2.xsd FROM file:///u/temp/cust2.xsd ADD http://mycompany.com/prod/cust3.xsd FROM file:///u/temp/cust3.xsd COMPLETE
