Loading TOC...
Administrator's Guide (PDF)

Administrator's Guide — Chapter 28

Understanding and Defining Schemas

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.

Understanding Schemas

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:

  1. If the XQuery program explicitly references a schema for the namespace in question, MarkLogic Server uses this reference.
  2. Otherwise, MarkLogic Server searches the schema database for an XML schema document whose target namespace is the same as the namespace of the element that MarkLogic Server is trying to type.
  3. If no matching schema document is found in the database, MarkLogic Server looks in its Config directory for a matching schema document.
  4. If no matching schema document is found in the 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:

  1. First, MarkLogic Server searches the schema database for a document with the exact URI you specified in the schema mapping.

    If the schema mapping for the HTTP, ODBC, or XDBC server conflicts with the schema mapping for the group, the former mapping is used.

  2. If no matching schema document is found in the schema database, MarkLogic Server looks in its Config directory for a schema document whose filename matches the filename portion of the URI you specified.
  3. If no matching schema document is found in the 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.

Procedures For Defining Schemas

Use the following procedures for defining schemas:

Adding a Schema Definition for a Group

To make a schema available to all HTTP, ODBC, or XDBC servers in a group, complete the following procedure:

  1. Click the Groups icon on the left tree menu.
  2. Click the group in which you want to define the schema.
  3. Click the Schemas icon on the left tree menu, under the specified group.
  4. Click the Add tab. The Schema Configuration page displays:

  5. Enter a namespace URI and corresponding schema location.

    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:

    PlatformSchema Directory
    Microsoft Windows C:\Program Files\MarkLogic\Config
    Red Hat Linux/opt/MarkLogic/Config
    Sun Solaris/opt/MARKlogic/Config
  6. To add more schema definitions, click the More Items button and repeat step 5 for other schemas as needed.
  7. Scroll to the top or bottom and click OK.

The schema is added to the group.

Adding a Schema Definition for an HTTP, ODBC, or XDBC Server

To make a schema available to a particular HTTP, ODBC, or XDBC server, perform the following steps:

  1. Click the Groups icon on the left tree menu.
  2. Click the name of the group which contains the HTTP, ODBC, or XDBC server to which you want to add a schema.
  3. Click the App Servers icon.
  4. Click the name of the App Server to which you want to add a schema.
  5. Click the Schemas icon on the left tree menu, under the specified App Server.
  6. Click the Add tab. The Schema Configuration page displays:

  7. Enter a namespace URI and corresponding schema location.

    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:

    PlatformSchema Directory
    Microsoft Windows C:\Program Files\MarkLogic\Config
    Red Hat Linux/opt/MarkLogic/Config
    Sun Solaris/opt/MARKlogic/Config
  8. To add more schema definitions, click the More Items button and repeat step 7 for other schemas as needed.
  9. Scroll to the top or bottom and click OK.

The schema is added to the HTTP, ODBC, or XDBC server.

Viewing Schema Definitions for a Group

To view a schema definition for a group, complete the following procedure:

  1. Click the Groups icon on the left tree menu.
  2. Click the group that contains the schema you want to view.
  3. Click the Schemas icon on the left tree menu, under the specified group.

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.

Viewing Schema Definitions for an HTTP, ODBC, or XDBC Server

To view a schema definition for an HTTP or XDBC Server, perform the following steps:

  1. Click the Groups icon on the left tree menu.
  2. Click on the name of the group which contains the HTTP , ODBC, or XDBC server with the schema you want to view.
  3. Click the App Servers icon.
  4. Click the name of the App Server with the schema you want to view.
  5. Click the Schemas icon on the left tree menu, under the specified App Server.

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.

Deleting a Schema Definition for a Group

To delete a schema definition for a group, perform the following steps:

  1. Click the Groups icon on the left tree menu.
  2. Click the group from which you want to delete the schema.
  3. Click the Schemas icon on the left tree menu, under the specified group.
  4. Locate the schema definition to be deleted from the system and click Delete.
  5. A confirmation message displays. Confirm the delete and click OK.

The schema is dropped from the group.

Deleting a Schema Definition for an HTTP, ODBC, or XDBC Server

To delete a schema definition for an HTTP, ODBC, or XDBC server, perform the following steps:

  1. Click the Groups icon on the left tree menu.
  2. Click the name of the group which contains the HTTP, ODBC, or XDBC server with the schema you want to delete.
  3. Click the App Servers icon.
  4. Click the name of the App Server with the schema you want to delete.
  5. Click the Schemas icon on the left tree menu, under the specified App Server.
  6. Click the Schemas icon on the left tree menu, under the specified App Server.
  7. Locate the schema definition to be deleted from the system and click Delete.
  8. A confirmation message displays. Confirm the delete and click OK.

The schema is dropped from the App Server.

« Previous chapter
Next chapter »
Powered by MarkLogic Server 7.0-4.1 and rundmc | Terms of Use | Privacy Policy