tsd:unique

Purpose

This element specifies that a field is to be a unique key, as described in the section Definition of Unique Keys of the Tamino XML Schema User Guide. If present, checks on uniqueness are performed for the single key or combination of keys that are specified in the xpath attribute of the tsd:field child element(s).

Parent element tsd:logical
Child elements

tsd:field

Note:
A tsd:unique element can have an arbitrary number of tsd:field child elements.

Attributes name
Restrictions

The tsd:field child element may only point to elements and attributes that have multiplicity 1 and are not of one of the following types:

Attributes
Name Type Description
name xs:NCName

This required attribute specifies the name of the uniqueness constraint under which it can subsequently be referenced.

The name must be unique within the scope of a single doctype.

Example 1

This example demonstrates the use of the tsd:unique element and its subelement tsd:field to define two unique keys. One unique key definition is intended for the combined key comprising the element C and the attribute b of element B. The other one is intended for a single key consisting of the element D.

<tsd:doctype name="A">
  .
  .
  .
  <tsd:unique name="CB-key">
    <tsd:field xpath="C" />
    <tsd:field xpath="B/@b" />
  </tsd:unique>
  <tsd:unique name="D-key">
    <tsd:field xpath="D" />
  </tsd:unique>
  .
  .
  .
</tsd:doctype>

Example 2

Here is another example for the tsd:unique element. It shows how to impose a uniqueness constraint on the root element of the schema.

<tsd:doctype name="A">
  .
  .
  .
  <tsd:unique name="root-key">
    <tsd:field xpath="." />
  </tsd:unique>
  .
  .
  .
</tsd:doctype>