This chapter describes schemas and lists procedures for defining them. The following topics are included:
For more information on the Schema database, loading schemas into MarkLogic Server, and using schemas in your applications, see the Loading Schemas chapter of the Application Developer's Guide.
A schema is a data dictionary for your XML content. To specify a schema, you need to define the namespace to which the schema applies as well as the location of the schema file.
Schemas define the types of elements within XML documents. When knowing the type of an XML element would be beneficial to evaluating an XQuery program, MarkLogic Server will look for the relevant schema document (based on that element's namespace) using the following strategy:
Config
directory for a matching schema document.Config
directory, no schema is found. Problems can arise in step 2 above when there are multiple schema documents in the schema database whose target namespace matches the namespace of the element that MarkLogic Server is trying to type. In this case, it is convenient to be able to use the Admin Interface to specify a default mapping.
Schema mappings can be specified for the HTTP, ODBC, or XDBC servers individually or for the group to apply to all HTTP, ODBC, or XDBC servers in the group. If the schema mapping defined for an HTTP, ODBC, or XDBC server conflicts with the schema mapping defined for the group, the former mapping is used.
When you specify a schema mapping in the Admin Interface, MarkLogic Server uses the following strategy to locate the schema:
If the schema mapping for the HTTP, ODBC, or XDBC server conflicts with the schema mapping for the group, the former mapping is used.
Config
directory for a schema document whose filename matches the filename portion of the URI you specified.Config
directory, no schema is found.If a namespace is invoked by one or more data elements stored in a particular database, and the schema for that namespace is defined for the group or HTTP, ODBC, or XDBC server, MarkLogic Server applies the schema to the storage, indexing, and retrieval of that data.
The schema database in this case is the schema database for the database in which the data is located.
Use the following procedures for defining schemas:
To make a schema available to all HTTP, ODBC, or XDBC servers in a group, complete the following procedure:
If you are planning to store the schema in your Config
directory, the following table lists the default location of the Config
directory on each platform:
Platform | Schema Directory |
---|---|
Microsoft Windows | C:\Program Files\MarkLogic\Config |
Red Hat Linux | /opt/MarkLogic/Config |
Mac OS X | ~/Library/MarkLogic/Config/ |
To make a schema available to a particular HTTP, ODBC, or XDBC server, perform the following steps:
If you are planning to store the schema in your config directory, refer to the following table for the default location of the config directory on your platform:
Platform | Schema Directory |
---|---|
Microsoft Windows | C:\Program Files\MarkLogic\Config |
Red Hat Linux | /opt/MarkLogic/Config |
Mac OS X | ~/Library/MarkLogic/Config/ |
To view a schema definition for a group, complete the following procedure:
The following example shows just one schema. It specifies that the schema for namespace http://www.w3.org/1999/xhtml
is found in the file xhtml.1.xsd
, which is located in the config directory of your MarkLogic Server program directory.
To view a schema definition for an HTTP or XDBC Server, perform the following steps:
The following example shows just one schema. It specifies that the schema for namespace http://www.w3.org/1999/xhtml
is found in the file xhtml.1.xsd
, which is located in the config directory of your MarkLogic Server program directory.
To delete a schema definition for a group, perform the following steps:
To delete a schema definition for an HTTP, ODBC, or XDBC server, perform the following steps: