Databases Reference
In-Depth Information
Example 2-5 Using XMLSERIALIZE function
select xmlserialize (review as varchar(500)) from moviereview
If the SERIALIZE function is not used when selecting an XML column, the XML
value is serialized to BLOB value implicitly.
2.2.6 Schema support
XML schema defines the structure of the XML document, including the element
definition, attribute definition, namespaces, code pages, and so on. These
schemas can be used to validate the XML value before inserting these values
into the database table. Generally these schemas are stored in the file system
and need to be registered to the database before using them for validation.
Registering a schema to the database makes the schema a database entity and
removes the dependency of reading the content of the schema document from
the operating system. DB2 provides two ways of registering the schema to the
database.
Registration using CLP commands
DB2 introduced new CLP commands to register a schema to the database. To
register the database using the CLP commands, follow these steps:
1. Register the primary schema document.
The primary schema document is the one at the top of the import/include
hierarchy. Register the main schema document using the following
command:
register xmlschema < namespace URI > from < location URI > with
< property URI > as < relational id >
The terms in the command are as follows:
- Namespace Uniform Resource Identifier (URI): Namespace of the XML
document which will be referenced from XML documents.
- Location URI: Physical location of the schema file in the file system.
- Property URI: Physical location of the property document associated with
the schema document in the file system.
2. Add the secondary schemas document.
Add the XML schema document referenced (using the include or import tag)
in the main schema document or any of the already added secondary schema
documents:
add xmlschema document to < relation id of main schema > add < document
URI > from < location URI > with < property URI >
Search WWH ::




Custom Search