ISO/IEC JTC1/SC34
Title: | Topic Maps Constraint Language |
---|---|
Source: | Graham Moore, Dmitry Bogachev, JTC1 / SC34 |
Project: | ISO 19756: Topic Maps Constraint Language |
Project editor: | Graham Moore, Dmitry Bogachev |
Status: | Final Committee Draft |
Action: | For review |
Date: | 2010-03-25 |
Summary: | |
Distribution: | SC34 and Liaisons |
Refer to: | http://www.isotopicmaps.org/tmcl/2010-03-25/ |
Supercedes: | http://www.isotopicmaps.org/tmcl/2009-10-19/ |
ISO (the International Organization for Standardization) and IEC (the International Electrotechnical Commission) form the specialized system for worldwide standardization. National bodies that are members of ISO or IEC participate in the development of International Standards through technical committees established by the respective organization to deal with particular fields of technical activity. ISO and IEC technical committees collaborate in fields of mutual interest. Other international organizations, governmental and non-governmental, in liaison with ISO and IEC, also take part in the work. In the field of information technology, ISO and IEC have established a joint technical committee, ISO/IEC JTC 1.
International Standards are drafted in accordance with the rules given in the ISO/IEC Directives, Part 2.
ISO/IEC 19756 was prepared by Joint Technical Committee ISO/IEC JTC 1, Information Technology, Subcommittee SC 34, Document Description and Processing Languages.
TMCL is a constraint language for Topic Maps, allowing definitions of Topic Maps schemas to be written in a precise and machine-readable form. This makes it possible to validate a topic map against a TMCL schema to see if it conforms to the constraints in the schema, and also enables a number of other uses, such as schema-driven editors, object mappings, and so on.
TMCL is defined as a Topic Maps vocabulary consisting of a number of topic, association, occurrence, and role types, identified by Published Subject Identifiers (PSIs), and defined using English prose. TMCL defines the concept of validation, by which a given topic map is valid according to a schema if it conforms to all the constraints in that schema and a number of additional constraints which apply to all topic maps independent of schema.
TMCL does not have any syntax of its own, since it is defined simply as a Topic Maps vocabulary. However, a number of CTM templates are defined in this standard in order to facilitate authoring of TMCL schemas using CTM.
This International Standard defines a Topic Maps vocabulary for representing constraints on Topic Maps instance data, defined using English prose. The vocabulary is defined in terms of validation, that is, verifying whether or not a given topic map conforms to the constraints. It may have many other applications, but these are not described in this International Standard.
The following referenced documents are indispensable for the application of this document. For dated references, only the edition cited applies. For undated references, the latest edition of the referenced document (including any amendments) applies.
Each of the following documents has a unique identifier that is used to cite the document in the text. The unique identifier consists of the part of the reference up to the first comma.
TMDM, ISO 13250-2:2006 Information Technology — Document Description and Processing Languages — Topic Maps — Data Model, ISO, 2006, http://www.isotopicmaps.org/sam/sam-model/
TMQL, ISO 18048 Information Technology — Document Description and Processing Languages — Topic Maps — Query Language, ISO, http://www.isotopicmaps.org/tmql/
CTM, ISO 13250-5 Information Technology — Document Description and Processing Languages — Topic Maps — Compact Syntax, ISO, http://www.isotopicmaps.org/ctm/
XML Schema-2, XML Schema Part 2: Datatypes Second Edition, W3C Recommendation, 28 October 2004, http://www.w3.org/TR/2004/REC-xmlschema-2-20041028/
The TMCL validation rules are defined in English prose using constructs from TMDM ([TMDM]), and written according to certain conventions, whereby some of the phrases in the text have particular interpretations. These phrases and their interpretations are given in the following clauses.
Throughout this clause the defined phrases contain placeholders
given as variables (written thus: v) in the definitions.
When the phrases are used, these placeholders are defined either by
reference to topics already defined in the context where the phrase is
used, or using a qname (an identifying token of the form
foo:bar
). Qnames are expanded into full IRIs using the
prefix declarations in Clause 5, and refer to the
topic item which has that IRI in its [subject
identifiers]
property.
The namespace prefix tmdm:
is used throughout this International Standard
in qnames as a shorthand for the following namespace
http://psi.topicmaps.org/iso13250/model/
. Thus,
tmdm:bar
refers to the IRI
http://psi.topicmaps.org/iso13250/model/bar
. Similarly,
iso:
is a shorthand for
http://psi.topicmaps.org/iso13250/
.
The topic tmdm:subject
represents the concept of a
subject as defined in [TMDM], and so is the type of which
all topics, statements, and association roles are instances, and the
common supertype of all types. In TMCL it is used in constraints to
make it clear that any topic whatsoever may appear in a particular
slot in an ontology.
In order to support this even when topic maps do not contain the
implied tmdm:type-instance
and
tmdm:supertype-subtype
associations the validation rules
give tmdm:subject
special treatment, as described
below.
The tmdm:subject
PSI is not defined in [TMDM]. This is the clause defining it.
To follow an association of type at from a topic
t means traversing all associations of type at.
A is the set of all the association items a in
the [parent]
properties of all the role items in the
[roles played]
property of t where
a's [type] property contains at or some subtype
of at.
The end result of the traversal is the set of topic items in the
[player]
property of each role item r in
a's [roles]
property, except where
r is contained in t's [roles
played]
property.
To follow an association of type at to roles of type
rt from a topic t means traversing all
associations of type at. A is the set of all the
association items a in the [parent]
properties
of all the role items in the [roles played]
property of
t where a's [type] property contains
at or a subtype of at.
The end result of the traversal is the set of topic items in the
[player]
property of each role item r in
a's [roles]
property, except where
r is contained in t's [roles
played]
property, or where r's [type]
property does not contain rt or some subtype of
rt.
A topic t is said to play a role of type rt
in an association of type at when t's
[roles played]
property contains at least one role item
r whose [type]
property contains rt
(or some subtype of rt) and r's
[parent]
property contains an association item whose
[type]
property contains at or some subtype of
at.
A topic type t1 is said to be an subtype of the topic
type t2 if following the association type
tmdm:supertype-subtype
from t1 to roles of
type tmdm:supertype
produces either t2 or a
subtype of t2. If t2 is
tmdm:subject
then t1 is a subtype of it even
if the necessary tmdm:supertype-subtype
associations are
not present.
A topic t is said to be an instance of the topic type
tt if following the association type
tmdm:type-instance
from t produces either
tt, a subtype of tt, or if tt is
tmdm:subject
.
A statement s (as defined in [TMDM]) is said
to be an instance of the statement type st if the
s's [type] property contains either st, a
subtype of st, or if st is
tmdm:subject
.
A string s matches a regular expression r if
the string is a member of the set of strings L(r)
denoted
by r as defined in appendix F of [XML Schema-2].
The value of a topic t's occurrence of type
ot is referred to as v, and produced by finding
the occurrence item o in t's
[occurrences]
property whose [type]
property
contains ot or some subtype of ot. If no such
occurrence exists there is no given value. It is an error if there is
more than one such occurrence.
When comparing tmcl:card-min
and
tmcl:card-max
values, in addition to the ordinary
integers, one may encounter the special value *
of
datatype iso:ctm-integer
. This special value is used to
indicate unlimited cardinality, and compares as larger than any
specific integer.
This International Standard defines two kinds of rules:
Constraint validation rules, which specify how to validate
the constraint represented by an individual topic that is an
instance of some subclass of tmcl:constraint
.
Global validation rules, which are not tied to any specific constraint topic, and which apply to the entire topic map.
A schema is a set of constraint topics, declaration topics, topic types, association types, role types, name types, and occurrence types contained in a topic map.
A topic map is valid according to a schema if the topic map is valid according to each individual constraint in the schema, and if the topic map is valid according to all the global validation rules specified in this International Standard.
This is a very strict form of validation, which may not be suitable for all situations. Implementations may choose to allow users to turn off any set of constraints they choose in order to allow more flexible forms of validation.
A topic map is valid according to a constraint if the topic map satisifies the constraint validation rule defined for the constraint type of which the constraint topic is an instance.
TMCL does not dictate when constraints should be applied, nor does it state what it means to a controlling application when it is found that a given constraint is violated.
The validation rules defined in this International Standard assume that the schema and
the instance data are located in the same topic map. If this is not
the case, implementations shall behave as though the schema and
instance topic maps were merged. This includes any schemas included by
using tmcl:includes-schema
, even though these schemas may
physically reside in other topic maps.
In order to avoid having to declare the most basic topics used in most topic maps, processors shall behave as though the following declarations were present in every TMCL schema:
tmdm:topic-name isa tmcl:name-type. tmdm:supertype-subtype isa tmcl:association-type; has-role(tmdm:subtype, 1, 1); has-role(tmdm:supertype, 1, 1). tmdm:subtype isa tmcl:role-type. tmdm:supertype isa tmcl:role-type. tmdm:type-instance isa tmcl:association-type; has-role(tmdm:type, 1, 1); has-role(tmdm:instance, 1, 1). tmdm:type isa tmcl:role-type. tmdm:instance isa tmcl:role-type. tmcl:topic-type isa tmcl:topic-type; plays-role(tmdm:type, tmdm:type-instance, 0, *); plays-role(tmdm:supertype, tmdm:supertype-subtype, 0, *); plays-role(tmdm:subtype, tmdm:supertype-subtype, 0, *). tmdm:subject isa tmcl:topic-type; plays-role(tmdm:instance, tmdm:type-instance, 0, *). |
TMCL has no syntax of its own, but since TMCL schemas are
represented as topic maps, any Topic Maps representation can be used
to create a TMCL schema. The schema shall, however, be valid according
to the TMCL meta-schema in Annex B, although the
schema need not conform to the global validation rules. The values of
all occurrences of type tmcl:regexp
shall be valid regular
expressions as defined in [XML Schema-2].
Throughout this International Standard all examples are given using the CTM syntax
[CTM], and to facilitate the authoring of TMCL in CTM a
number of templates are defined. These templates exist in a resource
http://www.isotopicmaps.org/tmcl/templates.ctm
that can
be downloaded and included in any CTM file.
To include the TMCL templates the following CTM include directive can be used:
%include http://www.isotopicmaps.org/tmcl/templates.ctm |
The following prefixes are used throughout this document:
%prefix tmcl http://psi.topicmaps.org/tmcl/ %prefix tmdm http://psi.topicmaps.org/iso13250/model/ %prefix xsd http://www.w3.org/2001/XMLSchema# |
TMCL provides a number of constructs known as declarations, which allow Topic Maps constructs to be used in ways which would otherwise be forbidden by the global validation rules. Declarations are in a sense the opposite of constraints, in that their effect is to relax constraints built into TMCL.
Making a topic an instance of tmcl:topic-type
is a
declaration that the topic may be used as a topic type.
Declaring person
a topic type:
person isa tmcl:topic-type . |
Global Validation Rule: any topic t which plays a
role of type tmdm:type
in an association of type
tmdm:type-instance
, but which is not an instance of
tmcl:topic-type
, is invalid.
Making a topic an instance of tmcl:name-type
is a
declaration that the topic may be used as a name type.
Declaring nickname
a name type:
nickname isa tmcl:name-type . |
Global Validation Rule: any topic name item n
whose [type]
property contains a topic item t
where t is not an instance of tmcl:name-type
is invalid.
Making a topic an instance of tmcl:occurrence-type
is
a declaration that the topic may be used as an occurrence type.
Declaring date-of-birth
an occurrence type:
date-of-birth isa tmcl:occurrence-type . |
Global Validation Rule: any occurrence item o
whose [type]
property contains a topic item t
where t is not an instance of
tmcl:occurrence-type
is invalid.
Making a topic an instance of tmcl:association-type
is
a declaration that the topic may be used as an association type.
Declaring that works-for
is an association type:
works-for isa tmcl:association-type . |
Global Validation Rule: any association item a
whose [type]
property contains a topic item t
where t is not an instance of
tmcl:association-type
is invalid.
Making a topic an instance of tmcl:role-type
is a
declaration that the topic may be used as a role type.
Declaring containee
a role type:
containee isa tmcl:role-type . |
Global Validation Rule: any association role item
r whose [type]
property contains a topic item
t where t is not an instance of
tmcl:role-type
is invalid.
The tmcl:overlap-declaration
is used to declare that
the sets of instances of two or more topic types are non-disjoint
(that is, that they may overlap). The default is that the instance
sets of different topic types are disjoint.
The following declares that the topic types person
and
employee
overlap:
person isa tmcl:topic-type; overlaps(employee). |
The following CTM template is defined:
def overlaps($tt1, $tt2) ?c isa tmcl:overlap-declaration. tmcl:overlaps(tmcl:allows : ?c, tmcl:allowed : $tt1) tmcl:overlaps(tmcl:allows : ?c, tmcl:allowed : $tt2) end |
Global Validation Rule: the set of all the topic types of which a given topic t is an instance is referred to as TT. t is invalid if there exists a pair of different topics t1 and t2 in TT such that:
t1 is not a subtype of t2 (or vice versa), and
there does not exist a c which is an instance of
tmcl:overlap-declaration
and where following the
tmcl:overlaps
association from c
produces both t1 and t2.
The tmcl:constraint
topic type is used as the base
type for all topic types that are considered constraint types. It is
an abstract type used simply to group the constraint types for ease of
schema introspection.
The tmcl:abstract-constraint
provides a way to express
that a given topic type shall not have any direct instances.
The following states that creature
is an abstract
topic type:
creature isa tmcl:topic-type; is-abstract(). |
The following CTM template is defined:
def is-abstract($tt) ?c isa tmcl:abstract-constraint. tmcl:constrained-topic-type(tmcl:constraint : ?c, tmcl:constrained : $tt) end |
Constraint Validation Rule for all constraints c
of type tmcl:abstract-constraint
: c applies to
a topic type t, which can be found by following
associations of type tmcl:constrained-topic-type
from the
c topic. t violates the constraint if it plays
the role of type tmdm:type
in any association of type
tmdm:type-instance
.
A subject identifier constraint provides a way to constrain the subject identifiers of instances of a given topic type. The constraint specifies:
card-min
, indicating the minimum number of
subject identifiers a valid instance shall have
card-max
, indicating the maximum number of
subject identifiers a valid instance can have, and
regexp
, a regular expression the subject
identifier shall match.
The following states that topics of type person
shall have zero or one subject identifier:
person isa tmcl:topic-type; has-subject-identifier(0, 1, ".*"). |
The following CTM template is defined:
def has-subject-identifier($tt, $min, $max, $regexp) ?c isa tmcl:subject-identifier-constraint; tmcl:card-min: $min; tmcl:card-max: $max; tmcl:regexp: $regexp. tmcl:constrained-topic-type(tmcl:constraint : ?c, tmcl:constrained : $tt) end |
Constraint Validation Rule for all constraints c
of type tmcl:subject-identifier-constraint
: c
applies to a topic type t, which can be found by following
the tmcl:constrained-topic-type
association from
c
. The constraint has the following properties:
r, which is the value of c's
occurrence of type tmcl:regexp
if given, and
".*"
if not,
min, which is the value of
c's tmcl:card-min
occurrence, if given, and
0
, if not, and
max, which is the value of
c's tmcl:card-max
occurrence, if given, and
undefined, if not.
For each instance i of t the set of its subject identifiers which match r is referred to as S. i violates c if the cardinality of S is lower than min or greater than max (provided max is not undefined).
A subject locator constraint provides a way to constrain the subject locators of instances of a given topic type. The constraint specifies:
card-min
, indicating the minimum number of
subject locators a valid instance shall have
card-max
, indicating the maximum number of
subject locators a valid instance can have, and
regexp
, a regular expression that the subject
locator shall match.
The following states that topics of type document
shall have at least one subject locator:
document isa tmcl:topic-type; has-subject-locator(1, *, ".*"). |
The following CTM template is defined:
def has-subject-locator($tt, $min, $max, $regexp) ?c isa tmcl:subject-locator-constraint; tmcl:card-min: $min; tmcl:card-max: $max; tmcl:regexp: $regexp. tmcl:constrained-topic-type(tmcl:constraint : ?c, tmcl:constrained : $tt) end |
Constraint Validation Rule for all constraints c
of type tmcl:subject-locator-constraint
: c
applies to a topic type t, which can be found by following
the tmcl:constrained-topic-type
association from
c
. The constraint has the following properties:
r, which is the value of c's
occurrence of type tmcl:regexp
if given, and
".*"
if not,
min, which is the value of
c's tmcl:card-min
occurrence, if given, and
0
, if not, and
max, which is the value of
c's tmcl:card-max
occurrence, if given, and
undefined, if not.
For each instance i of t the set of its subject locators which match r is referred to as S. i violates c if the cardinality of S is lower than min or greater than max (provided max is not undefined).
An item identifier constraint provides a way to constrain the item identifiers of topic map constructs of a given type. The constraint specifies:
card-min
, indicating the minimum number of
item identifiers a valid instance shall have
card-max
, indicating the maximum number of
item identifiers a valid instance can have, and
regexp
, a regular expression that the item
identifier shall match.
The following states that topics of type document
shall have at least one item identifier:
document isa tmcl:topic-type; has-item-identifier(1, *, ".*"). |
The following CTM template is defined:
def has-item-identifier($tt, $min, $max, $regexp) ?c isa tmcl:item-identifier-constraint; tmcl:card-min: $min; tmcl:card-max: $max; tmcl:regexp: $regexp. tmcl:constrained-construct(tmcl:constraint : ?c, tmcl:constrained : $tt) end |
Constraint Validation Rule for all constraints c
of type tmcl:item-identifier-constraint
: c
applies to a Topic Maps construct t, which can be found by
following the tmcl:constrained-construct
association
from c
. The constraint has the following properties:
r, which is the value of c's
occurrence of type tmcl:regexp
if given, and
".*"
if not,
min, which is the value of
c's tmcl:card-min
occurrence, if given, and
0
, if not, and
max, which is the value of
c's tmcl:card-max
occurrence, if given, and
undefined, if not.
For each instance i of t the set of its item identifiers which match r is referred to as S. i violates c if the cardinality of S is lower than min or greater than max (provided max is not undefined).
A topic name constraint provides a way to constrain the type and cardinality of topic names for instances of a given topic type, and has the following properties:
card-min
, indicating the minimum number of names
a valid instance shall have, and
card-max
, indicating the maximum number of names
a valid instance shall have.
The following states that topics of type person
shall
have exactly one name of type tmdm:topic-name
:
person isa tmcl:topic-type; has-name(tmdm:topic-name, 1, 1). |
The following CTM template is defined:
def has-name($tt, $nt, $min, $max) ?c isa tmcl:topic-name-constraint; tmcl:card-min: $min; tmcl:card-max: $max. tmcl:constrained-topic-type(tmcl:constraint : ?c, tmcl:constrained : $tt) tmcl:constrained-statement(tmcl:constraint : ?c, tmcl:constrained : $nt) end |
Constraint Validation Rule for all constraints c
of type tmcl:topic-name-constraint
: c applies
to a topic type t, which can be found by following
associations of type tmcl:constrained-topic-type
from
c. The constraint has the following properties:
nt, which is obtained by following associations of
type tmcl:constrained-statement
from c,
min, which is the value of
c's tmcl:card-min
occurrence, if given, and
0
, if not, and
max, which is the value of
c's tmcl:card-max
occurrence, if given, and
undefined, if not.
For each instance i of t the set of its topic names of type nt is referred to as N. i violates c if the cardinality of N is lower than min or greater than max (provided max is not undefined).
Global Validation Rule: any topic name n, whose
type is referred to as t, is invalid if no constraint
c that is an instance of
tmcl:topic-name-constraint
can be found such that the
topic found by following c's
tmcl:constrained-statement
associations is
t.
A variant name constraint provides a way to constrain the scope and cardinality of variant names for topic names on instances of a given topic type, and has the following properties:
card-min
, indicating the minimum number of names
a valid instance shall have for each topic name, and
card-max
, indicating the maximum number of names
a valid instance shall have for each topic name.
The following states that for topics of type person
the tmdm:topic-name
s shall have exactly one variant with
xtm:sort
in its scope:
person isa tmcl:topic-type; has-variant(tmdm:topic-name, xtm:sort, 1, 1). |
The following template is defined:
def has-variant($tt, $nt, $t, $min, $max) ?c isa tmcl:variant-name-constraint; tmcl:card-min: $min; tmcl:card-max: $max. tmcl:constrained-topic-type(tmcl:constraint : ?c, tmcl:constrained : $tt) tmcl:constrained-statement(tmcl:constraint : ?c, tmcl:constrained : $nt) tmcl:required-scope(tmcl:constraint : ?c, tmcl:constrained : $t) end |
Constraint Validation Rule for all constraints c
of type tmcl:variant-name-constraint
: c
applies to a topic type t, which can be found by following
associations of type tmcl:constrained-topic-type
from
c. The constraint has the following properties:
nt, which is obtained by following associations of
type tmcl:constrained-statement
from c,
s, which is obtained by following associations of
type tmcl:required-scope
from c,
min, which is the value of
c's tmcl:card-min
occurrence, if given, and
0
, if not, and
max, which is the value of
c's tmcl:card-max
occurrence, if given, and
undefined, if not.
For each instance i of nt which is attached to a topic of type tt the set of its variant names whose scopes contain s is referred to as N. i violates c if the cardinality of N is lower than min or greater than max (provided max is not undefined).
Global Validation Rule: any variant name v, whose
scope is referred to as S, is invalid if no constraint
c that is an instance of
tmcl:variant-name-constraint
can be found such that
the topic found by following c's
tmcl:constrained-statement
associations is
the same as the type of v's topic name,
the topic found by following c's
tmcl:constrained-topic-type
associations is
the same as the type of v's topic name's topic, and
the topic found by following c's
tmcl:required-scope
associations is an element of
S.
A topic occurrence constraint defines a way to constrain the type and cardinality of occurrences connected to a topic of a given type, and has the following properties:
card-min
, indicating the minimum number of
occurrences a valid instance shall have, and
card-max
, indicating the maximum number of
occurrences a valid instance may have.
The following states that topics of type person
shall
have exactly one occurrence of type date-of-birth
:
person isa tmcl:topic-type; has-occurrence(date-of-birth, 1, 1). |
The following CTM template is defined:
def has-occurrence($tt, $ot, $min, $max) ?c isa tmcl:topic-occurrence-constraint; tmcl:card-min: $min; tmcl:card-max: $max. tmcl:constrained-topic-type(tmcl:constraint : ?c, tmcl:constrained : $tt) tmcl:constrained-statement(tmcl:constraint : ?c, tmcl:constrained : $ot) end |
Constraint Validation Rule for all constraints c
of type tmcl:topic-occurrence-constraint
: c
applies to a topic type t, which can be found by following
the association of type tmcl:constrained-topic-type
from
c. The constraint has the following properties:
ot, which is obtained by following associations of
type tmcl:constrained-statement
from c,
min, which is the value of
c's tmcl:card-min
occurrence, if given, and
0
, if not, and
max, which is the value of
c's tmcl:card-max
occurrence, if given, and
undefined, if not.
For each instance i of t the set of its occurrences of type ot is referred to as O. i violates c if the cardinality of O is lower than min or greater than max (provided max is not undefined).
Global Validation Rule: any occurrence o, whose
type is referred to as t, is invalid if no constraint
c that is an instance of
tmcl:topic-occurrence-constraint
can be found such that
the topic found by following c's
tmcl:constrained-statement
associations is
t.
A topic role constraint constrains the types of roles topics of a given type can play in associations of a given type. It can also be seen as constraining the types of topics which may play roles of a given type in associations of a given type. It has the following properties:
card-min
, indicating the minimum number of
roles a valid instance shall have, and
card-max
, indicating the maximum number of
roles a valid instance can have.
The following states that topics of type person
shall
have exactly one role of type employee
in associations of
type works-for
:
person isa tmcl:topic-type; plays-role(employee, works-for, 1, 1). |
The following CTM template is defined:
def plays-role($tt, $rt, $at, $min, $max) ?c isa tmcl:topic-role-constraint; tmcl:card-min: $min; tmcl:card-max: $max. tmcl:constrained-topic-type(tmcl:constraint : ?c, tmcl:constrained : $tt) tmcl:constrained-statement(tmcl:constraint : ?c, tmcl:constrained : $at) tmcl:constrained-role(tmcl:constraint : ?c, tmcl:constrained : $rt) end |
Constraint Validation Rule for all constraints c
of type tmcl:topic-role-constraint
: c applies
to a topic type tt, which can be found by following the
association of type tmcl:constrained-topic-type
from
c. The constraint has the following properties:
rt, which is obtained by following associations of
type tmcl:constrained-role
from c,
at, which is obtained by following associations of
type tmcl:constrained-statement
from c,
min, which is the value of
c's tmcl:card-min
occurrence, if given, and
0
, if not, and
max, which is the value of
c's tmcl:card-max
occurrence, if given, and
undefined, if not.
For each instance i of tt the set of its roles of type rt is referred to as R. i violates c if the cardinality of R is lower than min or greater than max (provided max is not undefined).
Global Validation Rule: any association role r,
whose type is referred to as rt, and the type of whose
containing association is referred to as at, is invalid if
no constraint c that is an instance of
tmcl:topic-role-constraint
can be found such that the
topic found by following c's
tmcl:constrained-statement
associations is at
and such that the topic found by following c's
tmcl:constrained-role
associations is rt.
A tmcl:scope-constraint
constrains the types of topics
which may appear in the scope of a name, occurrence, or association of
a particular type, and has the following properties:
card-min
, indicating the minimum number of
roles a valid instance shall have, and
card-max
, indicating the maximum number of
roles a valid instance can have.
The following states that every occurrence of type
description
shall have exactly one topic of type
language
in its scope:
description isa tmcl:occurrence-type; has-scope(language, 1, 1). |
The following CTM template is defined:
def has-scope($st, $tt, $min, $max) ?c isa tmcl:scope-constraint; tmcl:card-min: $min; tmcl:card-max: $max. tmcl:constrained-statement(tmcl:constraint : ?c, tmcl:constrained : $st) tmcl:allowed-scope(tmcl:allows : ?c, tmcl:allowed : $tt) end |
Constraint Validation Rule for all constraints c
of type tmcl:scope-constraint
: c applies to a
name, occurrence, or association type st, which can be
found by following associations of type
tmcl:constrained-statement
from c. It has the
following properties:
t, which can be found by following associations
of type tmcl:allowed-scope
from c,
min, which is the value of
c's tmcl:card-min
occurrence, if given, and
0
, if not, and
max, which is the value of
c's tmcl:card-max
occurrence, if given, and
undefined, if not.
For any name, occurrence, or association s of type st the set of topics in its scope which are instances of t is referred to as S. s violates c if the cardinality of S is lower than min or greater than max (provided max is not undefined).
Global Validation Rule: For every topic t in the
scope of a name, occurrence, or association s, where
s's type is referred to as st, t may
be invalid, if the following does not hold. There shall exist a
constraint c, which shall be an instance of
tmcl:scope-constraint
, where following associations of
type tmcl:constrained-statement
from c shall
produce st, and following associations of type
tmcl:allowed-scope
from c shall produce at
least one topic type of which t is an instance.
A tmcl:scope-required-constraint
constrains the
appearance of a name, occurrence, or association of a particular type on
topics of a particular type with a given instance topic in its scope, and
has the following properties:
card-min
, indicating the minimum number of times
the given statement shall appear on topics of the given type,
and
card-max
, indicating the maximum number of
times the given statement shall appear on topics of the given type.
The following states that every topic of type category
shall have a description in the scope english
, and another
in the scope norwegian
:
description isa tmcl:occurrence-type; has-scope(language, 1, 1). category isa tmcl:topic-type; has-occurrence(description, 2, 2); requires-scope(description, english, 1, 1); requires-scope(description, norwegian, 1, 1). |
The following CTM template is defined:
def requires-scope($tt, $st, $t, $min, $max) ?c isa tmcl:scope-required-constraint; tmcl:card-min: $min; tmcl:card-max: $max. tmcl:constrained-topic-type(tmcl:constraint : ?c, tmcl:constrained : $tt) tmcl:constrained-statement(tmcl:constraint : ?c, tmcl:constrained : $st) tmcl:required-scope(tmcl:constraint : ?c, tmcl:constrained : $t) end |
Constraint Validation Rule for all constraints c
of type tmcl:scope-required-constraint
: c
applies to a name, occurrence, or association type st,
which can be found by following associations of type
tmcl:constrained-statement
from c. It has the
following properties:
tt, which can be found by following associations
of type tmcl:constrained-topic-type
from c,
t, which can be found by following associations
of type tmcl:required-scope
from c,
min, which is the value of
c's tmcl:card-min
occurrence, if given, and
0
, if not, and
max, which is the value of
c's tmcl:card-max
occurrence, if given, and
undefined, if not.
For any topic i of type tt
violates
c the set of its names, occurrences, and associations of
type st whose scopes contain t is known as
S. i violates c if the cardinality of
S is greater than max (provided max
is not undefined) or less than min.
A tmcl:reifier-constraint
constrains whether or not
names, occurrences, and associations of a given type may be reified,
and if so, what the type of the reifying topic shall be. Such
constraints have the following properties:
card-min
, indicating the minimum number of times
the statement shall be reified (which shall be 0 or 1), and
card-max
, indicating the maximum number of times
the statement can be reified (which shall be 0 or 1).
The following states that occurrences of type
date-of-birth
may not be reified:
date-of-birth isa tmcl:occurrence-type; cannot-have-reifier(). |
The following CTM templates are defined:
def must-have-reifier($st, $tt) ?c isa tmcl:reifier-constraint; tmcl:card-min: 1; tmcl:card-max: 1. tmcl:constrained-statement(tmcl:constraint: ?c, tmcl:constrained: $st) tmcl:allowed-reifier(tmcl:allows: ?c, tmcl:allowed: $tt) end def cannot-have-reifier($st) ?c isa tmcl:reifier-constraint; tmcl:card-min: 0; tmcl:card-max: 0. tmcl:constrained-statement(tmcl:constraint: ?c, tmcl:constrained: $st) tmcl:allowed-reifier(tmcl:allows: ?c, tmcl:allowed: tmdm:subject) end def may-have-reifier($st, $tt) ?c isa tmcl:reifier-constraint; tmcl:card-min: 0; tmcl:card-max: 1. tmcl:constrained-statement(tmcl:constraint: ?c, tmcl:constrained: $st) tmcl:allowed-reifier(tmcl:allows: ?c, tmcl:allowed: $tt) end |
Constraint Validation Rule for all constraints c
of type tmcl:reifier-constraint
: c applies to
a statement type st, which can be found by following
associations of type tmcl:constrained-statement
, and has
the following properties:
tt, which can be found by following associations
of type tmcl:allowed-reifier
,
min, which is the value of
c's tmcl:card-min
occurrence, if given, and
0
, if not, and
max, which is the value of
c's tmcl:card-max
occurrence, if given, and
undefined, if not.
Any topic t which is an instance of type tt and reifies a name, occurrence, or association s of type st violates c if max is 0.
Any name, occurrence, or association s of type st violates c if min is 1 and either s has no reifier, or s's reifier is not an instance of tt.
A tmcl:topic-reifies-constraint
constrains what types
of statements topics of a given type may reify, and has the following
properties:
card-min
, indicating the minimum number of times
the topic shall reify a statement (which shall be 0 or 1), and
card-max
, indicating the maximum number of times
the topic may reify a statement (which shall be 0 or 1).
The following states that topics of type person are not allowed to reify anything:
person isa tmcl:topic-type; cannot-reify(). |
The following CTM templates are defined:
def must-reify($tt, $st) ?c isa tmcl:topic-reifies-constraint; tmcl:card-min: 1; tmcl:card-max: 1. tmcl:constrained-topic-type(tmcl:constraint: ?c, tmcl:constrained: $tt) tmcl:constrained-statement(tmcl:constraint: ?c, tmcl:constrained: $st) end def cannot-reify($tt) ?c isa tmcl:topic-reifies-constraint; tmcl:card-min: 0; tmcl:card-max: 0. tmcl:constrained-topic-type(tmcl:constraint: ?c, tmcl:constrained: $tt) end def may-reify($tt, $st) ?c isa tmcl:topic-reifies-constraint; tmcl:card-min: 0; tmcl:card-max: 1. tmcl:constrained-topic-type(tmcl:constraint: ?c, tmcl:constrained: $tt) tmcl:constrained-statement(tmcl:constraint: ?c, tmcl:constrained: $st) end |
Constraint Validation Rule for all constraints c
of type tmcl:topic-reifies-constraint
: c
applies to a topic type t, which can be found by following
the association of type tmcl:constrained-topic-type from
c. The constraint has the following properties:
st, which can be found by following associations
of type tmcl:constrained-statement
(if nothing is
found, st is undefined),
min, which is the value of
c's tmcl:card-min
occurrence, if given, and
0
, if not, and
max, which is the value of c's
tmcl:card-max
occurrence, if given, and 1
,
if not.
For each instance i of t the construct reified by i is referred to as r. If there is no such construct, r is undefined.
i violates c if st is defined and r is not an instance of st, or if min is 1 and r is not defined, or if max is 0 and r is defined.
A tmcl:association-role-constraint
constrains the
number of roles of a particular type that may appear in associations
of a given type, and has a number of properties:
at
, the association type being constrained,
rt
, the role type being constrained,
card-min
, indicating the minimum number of times
the role can appear in the association, and
card-max
, indicating the maximum number of times
the role can appear in the association.
The following states that each association of type
works-for
shall have exactly one role of type
employee
and one of type employer
:
works-for isa tmcl:association-type; has-role(employee, 1, 1); has-role(employer, 1, 1). |
The following CTM template is defined:
def has-role($at, $rt, $min, $max) ?c isa tmcl:association-role-constraint; tmcl:card-min: $min; tmcl:card-max: $max. tmcl:constrained-statement(tmcl:constraint : ?c, tmcl:constrained : $at) tmcl:constrained-role(tmcl:constraint : ?c, tmcl:constrained : $rt) end |
Constraint Validation Rule for all constraints c
of type tmcl:association-role-constraint
: c
applies to an association type at, which can be found by
following the tmcl:constrained-statement
association from
c, and has the following properties:
rt, which can be found by following associations
of type tmcl:constrained-role
,
min, which is the value of
c's tmcl:card-min
occurrence, if given, and
0
, if not, and
max, which is the value of
c's tmcl:card-max
occurrence, if given, and
undefined, if not.
For each association a of type at the set of its roles which are of type rt is referred to as R. a violates c if the cardinality of R is lower than min or greater than max (unless max is undefined).
Global Validation Rule: for all association roles
r, r's type is referred to as rt, the
association it appears in is referred to as a, and
a's type is referred to as at. r is
invalid if there is no constraint c that is an instance of
tmcl:association-role-constraint
such that:
following c's tmcl:constrained-statement
association yields at, and
following c's tmcl:constrained-role
association yields rt.
The tmcl:role-combination-constraint
provides a way to
restrict which combinations of topic types are allowed to appear in
associations of a certain type together. The most common use case is
for a hierarchical association like contained-in
where a
continent may contain countries, countries may contain provinces, and
provinces may contain cities, but no other combinations (like a city
contained directly in a continent) are allowed.
The following states that the only allowed role player type combinations are (city, province), (province, country), (country, continent):
contained-in isa tmcl:association-type; has-role(containee, 1, 1); has-role(container, 1, 1); role-combination(containee, city, container, province); role-combination(containee, province, container, country); role-combination(containee, country, container, continent). |
The following CTM template is defined:
def role-combination($at, $rt, $tt, $ort, $ott) ?c isa tmcl:role-combination-constraint. tmcl:constrained-statement(tmcl:constraint: ?c, tmcl:constrained: $at) tmcl:constrained-role(tmcl:constraint: ?c, tmcl:constrained: $rt) tmcl:constrained-topic-type(tmcl:constraint: ?c, tmcl:constrained: $tt) tmcl:other-constrained-role(tmcl:constraint: ?c, tmcl:constrained: $ort) tmcl:other-constrained-topic-type(tmcl:constraint: ?c, tmcl:constrained: $ott) end |
Global Validation Rule: an association a of type
at, with a role r1 of type rt1 with
player rp1 which is a direct instance of tt1,
and another role r2 of type rt2 with player
rp2 which is a direct instance of tt2, is
invalid if there exists at least one c which is an instance
of tmcl:role-combination-constraint
and where following
c's associations of type
tmcl:constrained-statement
produces at, there
does not exist any c2 which is an instance of
tmcl:role-combination-constraint
and has the following
properties:
following c2's associations of type
tmcl:constrained-statement
produces at,
following c2's associations of type
tmcl:constrained-role
produces rt1,
following c2's associations of type
tmcl:constrained-topic-type
produces tt1,
following c2's associations of type
tmcl:other-constrained-role
produces rt2, and
following c2's associations of type
tmcl:other-constrained-topic-type
produces tt2.
A tmcl:occurrence-datatype-constraint
provides a way
to constrain the allowed datatype of an occurrence of a given
type.
The following states that all occurrences of type
date-of-birth
shall have the datatype
xsd:dateTime
:
date-of-birth isa tmcl:occurrence-type; has-datatype(xsd:dateTime). |
The following CTM template is defined:
def has-datatype($ot, $dt) ?c isa tmcl:occurrence-datatype-constraint; tmcl:datatype: $dt. tmcl:constrained-statement(tmcl:constraint : ?c, tmcl:constrained : $ot) end |
Constraint Validation Rule for all constraints c
of type tmcl:occurrence-datatype-constraint
: c
applies to an occurrence type t, which can be found by
following the tmcl:constrained-statement
association from
c. It has a datatype d
, which is the value of
c's tmcl:datatype
occurrence.
Any occurrence o of type t has a datatype known as d2, a value known as v, and violates constraint c if:
d2 is not d or XML Schema validly substitutable for it,
v is not XML Schema datatype valid according to d, and
v is not XML Schema datatype valid according to d2.
The tmcl:unique-value-constraint
provides a way to
require all names or occurrences of a given type to have different
values.
The following states that all occurrences of type
email
shall have different values:
email isa tmcl:occurrence-type; has-unique-value(). |
The following CTM template is defined:
def has-unique-value($st) ?c isa tmcl:unique-value-constraint. tmcl:constrained-statement(tmcl:constraint : ?c, tmcl:constrained : $st) end |
Constraint Validation Rule for all constraints c
of type tmcl:unique-value-constraint
: c
applies to a name or occurrence type st, which can be found
by following associations of type
tmcl:constrained-statement
from c. Any two
different names or occurrences s1 and s2 of type
st violate c if their values are equal.
The tmcl:regular-expression-constraint
provides a
mechanism for requiring that all values of a given name or occurrence
type shall match a given regular expression.
The following states that phone-number
occurrences
shall follow a particular syntax:
phone-number isa tmcl:occurrence-type; matches-regexp("(+47\s)?\d\d\s\d\d\s\d\d\s\d\d"). |
The following CTM template is defined:
def matches-regexp($st, $regexp) ?c isa tmcl:regular-expression-constraint; tmcl:regexp: $regexp. tmcl:constrained-statement(tmcl:constraint: ?c, tmcl:constrained: $st) end |
Constraint Validation Rule for all constraints c
of type tmcl:regular-expression-constraint
: c
applies to a name or occurrence type t, which can be found
by following associations of type
tmcl:constrained-statement
from c. It has a
regular expression r, which is the value of c's
tmcl:regexp
occurrence.
Any name or occurrence of type t whose value does not match the regular expression r violates c.
This clause defines a number of additional CTM templates, which are strictly speaking redundant, but which aid authoring by simplifying a number of common use cases.
The following template is used to define a binary association type and two role types:
def binary-association($at, $rt1, $rt2) $at isa tmcl:association-type; has-role($rt1, 1, 1); has-role($rt2, 1, 1). $rt1 isa tmcl:role-type. $rt2 isa tmcl:role-type. end |
The following template is used to define a binary symmetric association type and one role type:
def symmetric-association($at, $rt) $at isa tmcl:association-type; has-role($rt, 2, 2). $rt isa tmcl:role-type. end |
In addition to the predefined constraints provided by TMCL it is
possible for users to define their own constraints in order to define
more detailed limitations which the predefined constraints cannot
express. These constraints shall all be instances of some subtype of
tmcl:user-defined-constraint
. Two such subtypes are
provided by TMCL, but it is possible for users to define their own.
Each constraint type shall provide a TMQL expression which defines the
interpretation of the constraint.
tmcl:validation-expression
is an occurrence type used
on user-defined constraints, which contains a TMQL expression as
defined in [TMQL]. Its exact use and meaning depends on the
kind of user-defined constraint it is used with, as defined below.
A topic of type tmcl:denial-constraint
represents a
user-defined constraint whose tmcl:validation-expression
shall return nothing in order to be satisfied. That is, if the TMQL
query in the tmcl:validation-expression
returns a
non-empty result the constraint is violated.
The following constraint states that a person's
date-of-death
shall be equal to or later than the person's
date-of-birth
:
c isa tmcl:denial-constraint; tmcl:validation-expression " // person [ . / date-of-birth <= . / date-of-death ] ". |
Constraint Validation Rule for all constraints c
of type tmcl:denial-constraint
: c has an
attached query q, which is the value of its occurrence of
type tmcl:validation-expression
. The query q
is run against the topic map being validated, and if the query result
is non-empty c is violated.
A topic of type tmcl:requirement-constraint
represents
a user-defined constraint whose
tmcl:validation-expression
shall return at least one
result row in order to be satisfied. That is, if the TMQL query in the
tmcl:validation-expression
returns an empty result the
constraint is violated. As such it is the mirror image of
tmcl:denial-constraint
.
The following constraint states that the topic map shall contain at least one person topic:
c isa tmcl:requirement-constraint; tmcl:validation-expression " // person ". |
Constraint Validation Rule for all constraints c
of type tmcl:requirement-constraint
: c has an
attached query q, which is the value of its occurrence of
type tmcl:validation-expression
. The query q
is run against the topic map being validated, and if the query result
is empty c is violated.
TMCL provides a number of constructs which are not constraints or declarations, but which provide useful documentation to users. These constructs are defined in this clause.
The tmcl:schema
topic type is provided in order to
provide a standard mechanism for making assertions about schemas in
topic maps. Each topic of this type represents a TMCL schema.
The tmcl:belongs-to-schema
association type is used to
connect individual constraints and declarations with the schema. This
is useful in situations where a single topic map contains more than
one schema, in order to track what comes from which schema.
The following has an example of a schema containing a topic type and a constraint on that topic type:
example-schema isa tmcl:schema; - "Example schema". creature isa tmcl:topic-type; - "Creature"; belongs-to(example-schema). c isa tmcl:abstract-constraint; belongs-to(example-schema). tmcl:constrained-topic-type(tmcl:constraint : c, tmcl:constrained : creature) |
The following CTM template is defined:
def belongs-to($construct, $schema) tmcl:belongs-to-schema(tmcl:container: $schema, tmcl:containee: $construct) end |
The tmcl:version
occurrence type is used to attach
some identifier of the schema's version to the schema topic.
The following is an example of using tmcl:version
:
example-schema isa tmcl:schema; - "Example schema"; tmcl:version: "1.0". |
The tmcl:schema-resource
occurrence type is used to
refer from the schema topic to a resource that contains some
serialization of the schema.
The following is an example of using
tmcl:schema-resource
:
example-schema isa tmcl:schema; - "Example schema"; tmcl:schema-resource: http://example.org/example.ctm . |
The tmcl:includes-schema
association type is used to
reference another schema used in the current schema, in order to
import all its declarations and constraints. The importing of
declarations and constraints is done by the TMCL processor.
The following is an example of importing another schema:
example isa tmcl:schema; - "Example schema"; tmcl:schema-resource: http://example.org/example.ctm . sub isa tmcl:schema; - "Subschema"; tmcl:schema-resource: http://example.org/sub.ctm . tmcl:includes-schema(tmcl:container: example, tmcl:containee: sub) |
Three occurrence types which may be attached to any TMCL construct to document it are also provided, as described in this clause.
The tmcl:description
occurrence type is used to attach
a textual description of a TMCL construct to it inside the topic
map.
The tmcl:comment
occurrence type is used to attach any
textual information to a TMCL construct inside the topic map.
The tmcl:see-also
occurrence type is used to attach a
to a TMCL construct a reference to any kind of external information
about that construct.
The following shows example use of all three occurrence types:
creature isa tmcl:topic-type; tmcl:description: "A creature is any kind of living organism."; tmcl:comment: "Not sure if we need this. Should review."; tmcl:see-also: http://en.wikipedia.org/wiki/Creature . |
The tmcl:topic-map
topic type is is provided as a
mechanism for making assertions about topic maps. Each instance of
this topic type represents an individual topic map.
The tmcl:uses-schema
association type connects a
tmcl:topic-map
, playing the role of
tmcl:user
, with a tmcl:schema
topic, playing
the role of tmcl:used
, representing a schema used by that
topic map. This association is for documentation purposes only, and
does not affect the validation of the topic map in any way.
The following states that the topic map uses the TMCL meta-schema:
~ topicmap tmcl:uses-schema(tmcl:user: topicmap, tmcl:used: meta-schema) meta-schema isa tmcl:schema . |
There are two levels of conformance defined by this International Standard. In order to meet the requirements for Level One conformance, a TMCL processor shall be able to:
validate TMCL schemas and reject all schemas which are not valid according to the requirements in Clause 5, and
validate topic maps against valid TMCL schemas as defined in Clause 4, but without necessarily evaluating user-defined constraints, and report accurately whether or not each topic map is valid according to the schema.
This implies that level one processors are not required to support TMQL.
Further, Level One processors shall recognize the validly substitutable relationships between and be able to validate lexical values against the following datatypes:
xsd:anyURI,
xsd:decimal,
xsd:integer,
xsd:date,
xsd:dateTime,
xsd:string, and
iso:ctm-integer.
In order to satisfy Level Two conformance processors shall conform to Level One and in addition also evaluate user-defined constraints.
This implies that level two processors are required to support TMQL.
The CTM defined below is the same that can be located online at http://www.isotopicmaps.org/tmcl/templates.ctm
######################################################################### # TMCL - Topic Maps Constraint Language # This file defines the set of templates defined in the TMCL standard # This document is located at http://www.isotopicmaps.org/tmcl/templates.ctm # and is normative. # Draft version of 2010-03-25. ######################################################################### # prefix declarations %prefix tmcl http://psi.topicmaps.org/tmcl/ %prefix tmdm http://psi.topicmaps.org/iso13250/model/ # Overlap Declaration def overlaps($tt1, $tt2) ?c isa tmcl:overlap-declaration. tmcl:overlaps(tmcl:allows : ?c, tmcl:allowed : $tt1) tmcl:overlaps(tmcl:allows : ?c, tmcl:allowed : $tt2) end # Abstract Topic Type Constraint def is-abstract($tt) ?c isa tmcl:abstract-constraint. tmcl:constrained-topic-type(tmcl:constraint : ?c, tmcl:constrained : $tt) end # Subject Identifier Constraint def has-subject-identifier($tt, $min, $max, $regexp) ?c isa tmcl:subject-identifier-constraint; tmcl:card-min: $min; tmcl:card-max: $max; tmcl:regexp: $regexp. tmcl:constrained-topic-type(tmcl:constraint : ?c, tmcl:constrained : $tt) end # Subject Locator Constraint def has-subject-locator($tt, $min, $max, $regexp) ?c isa tmcl:subject-locator-constraint; tmcl:card-min: $min; tmcl:card-max: $max; tmcl:regexp: $regexp. tmcl:constrained-topic-type(tmcl:constraint : ?c, tmcl:constrained : $tt) end # Item Identifier Constraint def has-item-identifier($tt, $min, $max, $regexp) ?c isa tmcl:item-identifier-constraint; tmcl:card-min: $min; tmcl:card-max: $max; tmcl:regexp: $regexp. tmcl:constrained-construct(tmcl:constraint : ?c, tmcl:constrained : $tt) end # Topic Name Constraint def has-name($tt, $nt, $min, $max) ?c isa tmcl:topic-name-constraint; tmcl:card-min: $min; tmcl:card-max: $max. tmcl:constrained-topic-type(tmcl:constraint : ?c, tmcl:constrained : $tt) tmcl:constrained-statement(tmcl:constraint : ?c, tmcl:constrained : $nt) end # Variant Name Constraint def has-variant($tt, $nt, $t, $min, $max) ?c isa tmcl:variant-name-constraint; tmcl:card-min: $min; tmcl:card-max: $max. tmcl:constrained-topic-type(tmcl:constraint : ?c, tmcl:constrained : $tt) tmcl:constrained-statement(tmcl:constraint : ?c, tmcl:constrained : $nt) tmcl:required-scope(tmcl:constraint : ?c, tmcl:constrained : $t) end # Topic Occurrence Constraint def has-occurrence($tt, $ot, $min, $max) ?c isa tmcl:topic-occurrence-constraint; tmcl:card-min: $min; tmcl:card-max: $max. tmcl:constrained-topic-type(tmcl:constraint : ?c, tmcl:constrained : $tt) tmcl:constrained-statement(tmcl:constraint : ?c, tmcl:constrained : $ot) end # Topic Role Constraint def plays-role($tt, $rt, $at, $min, $max) ?c isa tmcl:topic-role-constraint; tmcl:card-min: $min; tmcl:card-max: $max. tmcl:constrained-topic-type(tmcl:constraint : ?c, tmcl:constrained : $tt) tmcl:constrained-statement(tmcl:constraint : ?c, tmcl:constrained : $at) tmcl:constrained-role(tmcl:constraint : ?c, tmcl:constrained : $rt) end # Scope Constraint def has-scope($st, $tt, $min, $max) ?c isa tmcl:scope-constraint; tmcl:card-min: $min; tmcl:card-max: $max. tmcl:constrained-statement(tmcl:constraint : ?c, tmcl:constrained : $st) tmcl:allowed-scope(tmcl:allows : ?c, tmcl:allowed : $tt) end # Scope Required Constraint def requires-scope($tt, $st, $t, $min, $max) ?c isa tmcl:scope-required-constraint; tmcl:card-min: $min; tmcl:card-max: $max. tmcl:constrained-topic-type(tmcl:constraint : ?c, tmcl:constrained : $tt) tmcl:constrained-statement(tmcl:constraint : ?c, tmcl:constrained : $st) tmcl:required-scope(tmcl:constraint : ?c, tmcl:constrained : $t) end # Reifier Constraint def must-have-reifier($st, $tt) ?c isa tmcl:reifier-constraint; tmcl:card-min: 1; tmcl:card-max: 1. tmcl:constrained-statement(tmcl:constraint: ?c, tmcl:constrained: $st) tmcl:allowed-reifier(tmcl:allows: ?c, tmcl:allowed: $tt) end def cannot-have-reifier($st) ?c isa tmcl:reifier-constraint; tmcl:card-min: 0; tmcl:card-max: 0. tmcl:constrained-statement(tmcl:constraint: ?c, tmcl:constrained: $st) tmcl:allowed-reifier(tmcl:allows: ?c, tmcl:allowed: tmdm:subject) end def may-have-reifier($st, $tt) ?c isa tmcl:reifier-constraint; tmcl:card-min: 0; tmcl:card-max: 1. tmcl:constrained-statement(tmcl:constraint: ?c, tmcl:constrained: $st) tmcl:allowed-reifier(tmcl:allows: ?c, tmcl:allowed: $tt) end # Topic Reifies Constraint def must-reify($tt, $st) ?c isa tmcl:topic-reifies-constraint; tmcl:card-min: 1; tmcl:card-max: 1. tmcl:constrained-topic-type(tmcl:constraint: ?c, tmcl:constrained: $tt) tmcl:constrained-statement(tmcl:constraint: ?c, tmcl:constrained: $st) end def cannot-reify($tt) ?c isa tmcl:topic-reifies-constraint; tmcl:card-min: 0; tmcl:card-max: 0. tmcl:constrained-topic-type(tmcl:constraint: ?c, tmcl:constrained: $tt) end def may-reify($tt, $st) ?c isa tmcl:topic-reifies-constraint; tmcl:card-min: 0; tmcl:card-max: 1. tmcl:constrained-topic-type(tmcl:constraint: ?c, tmcl:constrained: $tt) tmcl:constrained-statement(tmcl:constraint: ?c, tmcl:constrained: $st) end # Association Role Constraint def has-role($at, $rt, $min, $max) ?c isa tmcl:association-role-constraint; tmcl:card-min: $min; tmcl:card-max: $max. tmcl:constrained-statement(tmcl:constraint : ?c, tmcl:constrained : $at) tmcl:constrained-role(tmcl:constraint : ?c, tmcl:constrained : $rt) end # Role Combination Constraint def role-combination($at, $rt, $tt, $ort, $ott) ?c isa tmcl:role-combination-constraint. tmcl:constrained-statement(tmcl:constraint: ?c, tmcl:constrained: $at) tmcl:constrained-role(tmcl:constraint: ?c, tmcl:constrained: $rt) tmcl:constrained-topic-type(tmcl:constraint: ?c, tmcl:constrained: $tt) tmcl:other-constrained-role(tmcl:constraint: ?c, tmcl:constrained: $ort) tmcl:other-constrained-topic-type(tmcl:constraint: ?c, tmcl:constrained: $ott) end # Occurrence Data Type Constraint def has-datatype($ot, $dt) ?c isa tmcl:occurrence-datatype-constraint; tmcl:datatype: $dt. tmcl:constrained-statement(tmcl:constraint : ?c, tmcl:constrained : $ot) end # Unique Value Constraint def has-unique-value($st) ?c isa tmcl:unique-value-constraint. tmcl:constrained-statement(tmcl:constraint : ?c, tmcl:constrained : $st) end # Regular Expression Constraint def matches-regexp($st, $regexp) ?c isa tmcl:regular-expression-constraint; tmcl:regexp: $regexp. tmcl:constrained-statement(tmcl:constraint: ?c, tmcl:constrained: $st) end # Additional TMCL Templates def binary-association($at, $rt1, $rt2) $at isa tmcl:association-type; has-role($rt1, 1, 1); has-role($rt2, 1, 1). $rt1 isa tmcl:role-type. $rt2 isa tmcl:role-type. end # Additional TMCL Templates def symmetric-association($at, $rt) $at isa tmcl:association-type; has-role($rt, 2, 2). $rt isa tmcl:role-type. end # The Schema Topic def belongs-to($construct, $schema) tmcl:belongs-to-schema(tmcl:container: $schema, tmcl:containee: $construct) end |
This annex contains a TMCL schema for TMCL in CTM syntax, defining the allowed structure for TMCL schemas.
######################################################################### # TMCL - Topic Maps Constraint Language # This file is the TMCL schema that TMCL schemas must follow. # This document is located at http://www.isotopicmaps.org/tmcl/schema.ctm # and is normative. ######################################################################### %include http://www.isotopicmaps.org/tmcl/templates.ctm %prefix tmcl http://psi.topicmaps.org/tmcl/ %prefix tmdm http://psi.topicmaps.org/iso13250/model/ %prefix xsd http://www.w3.org/2001/XMLSchema# %prefix iso http://psi.topicmaps.org/iso13250/ # THE SCHEMA ITSELF tmcl-schema isa tmcl:schema; - "TMCL schema"; tmcl:version: "2010-03-25"; tmcl:description: "A meta-schema for TMCL, describing the allowed structure of TMCL schemas."; tmcl:see-also: http://www.isotopicmaps.org/tmcl/tmcl.html; tmcl:schema-resource: http://www.isotopicmaps.org/tmcl/2010-03-25/schema.ctm . # TOPIC TYPE tmcl:topic-type isa tmcl:topic-type; - "Topic type"; has-occurrence(tmcl:description, 0, 1); has-occurrence(tmcl:comment, 0, *); has-occurrence(tmcl:see-also, 0, *); plays-role(tmcl:constrained, tmcl:constrained-topic-type, 0, *); plays-role(tmcl:containee, tmcl:belongs-to, 0, *); plays-role(tmcl:allowed, tmcl:overlaps, 0, *); plays-role(tmcl:constrained, tmcl:other-constrained-topic-type, 0, *); plays-role(tmcl:allowed, tmcl:allowed-scope, 0, *); plays-role(tmcl:allowed, tmcl:allowed-reifier, 0, *); overlaps(tmcl:name-type); overlaps(tmcl:occurrence-type); overlaps(tmcl:association-type); overlaps(tmcl:role-type). # NAME TYPE tmcl:name-type isa tmcl:topic-type; - "Name type"; has-occurrence(tmcl:description, 0, 1); has-occurrence(tmcl:comment, 0, *); has-occurrence(tmcl:see-also, 0, *); plays-role(tmcl:constrained, tmcl:constrained-statement, 0, *); plays-role(tmcl:constrained, tmcl:constrained-construct, 0, *); plays-role(tmcl:containee, tmcl:belongs-to, 0, *). # OCCURRENCE TYPE tmcl:occurrence-type isa tmcl:topic-type; - "Occurrence type"; has-occurrence(tmcl:description, 0, 1); has-occurrence(tmcl:comment, 0, *); has-occurrence(tmcl:see-also, 0, *); plays-role(tmcl:constrained, tmcl:constrained-statement, 0, *); plays-role(tmcl:constrained, tmcl:constrained-construct, 0, *); plays-role(tmcl:containee, tmcl:belongs-to, 0, *). # ASSOCIATION TYPE tmcl:association-type isa tmcl:topic-type; - "Association type"; has-occurrence(tmcl:description, 0, 1); has-occurrence(tmcl:comment, 0, *); has-occurrence(tmcl:see-also, 0, *); plays-role(tmcl:constrained, tmcl:constrained-statement, 0, *); plays-role(tmcl:constrained, tmcl:constrained-construct, 0, *); plays-role(tmcl:containee, tmcl:belongs-to, 0, *). # ROLE TYPE tmcl:role-type isa tmcl:topic-type; - "Role type"; has-occurrence(tmcl:description, 0, 1); has-occurrence(tmcl:comment, 0, *); has-occurrence(tmcl:see-also, 0, *); plays-role(tmcl:constrained, tmcl:constrained-construct, 0, *); plays-role(tmcl:constrained, tmcl:constrained-role, 0, *); plays-role(tmcl:constrained, tmcl:other-constrained-role, 0, *); plays-role(tmcl:containee, tmcl:belongs-to, 0, *). # OVERLAP DECLARATION tmcl:overlap-declaration isa tmcl:topic-type; - "Overlap declaration"; has-occurrence(tmcl:description, 0, 1); has-occurrence(tmcl:comment, 0, *); has-occurrence(tmcl:see-also, 0, *); plays-role(tmcl:allows, tmcl:overlaps, 2, *); plays-role(tmcl:containee, tmcl:belongs-to, 0, 1). # CONSTRAINT tmcl:constraint isa tmcl:topic-type; isa tmcl:role-type; - "Constraint"; is-abstract(); has-occurrence(tmcl:description, 0, 1); has-occurrence(tmcl:comment, 0, *); has-occurrence(tmcl:see-also, 0, *); plays-role(tmcl:containee, tmcl:belongs-to, 0, 1). # CARD-MIN and CARD-MAX tmcl:card-min isa tmcl:occurrence-type; - "Minimum cardinality"; has-datatype(iso:ctm-integer). tmcl:card-max isa tmcl:occurrence-type; - "Maximum cardinality"; has-datatype(iso:ctm-integer). # REGEXP tmcl:regexp isa tmcl:occurrence-type; - "Regular expression"; has-datatype(xsd:string). # SUBJECT tmdm:subject - "Subject"; plays-role(tmcl:required, tmcl:required-scope, 0, *). # ABSTRACT CONSTRAINT tmcl:abstract-constraint ako tmcl:constraint; - "Abstract constraint"; plays-role(tmcl:constraint, tmcl:constrained-topic-type, 1, 1). # SUBJECT IDENTIFIER CONSTRAINT tmcl:subject-identifier-constraint ako tmcl:constraint; - "Subject identifier constraint"; has-occurrence(tmcl:card-min, 0, 1); has-occurrence(tmcl:card-max, 0, 1); has-occurrence(tmcl:regexp, 0, 1); plays-role(tmcl:constraint, tmcl:constrained-topic-type, 1, 1). # SUBJECT LOCATOR CONSTRAINT tmcl:subject-locator-constraint ako tmcl:constraint; - "Subject locator constraint"; has-occurrence(tmcl:card-min, 0, 1); has-occurrence(tmcl:card-max, 0, 1); has-occurrence(tmcl:regexp, 0, 1); plays-role(tmcl:constraint, tmcl:constrained-topic-type, 1, 1). # ITEM IDENTIFIER CONSTRAINT tmcl:item-identifier-constraint ako tmcl:constraint; - "Item identifier constraint"; has-occurrence(tmcl:card-min, 0, 1); has-occurrence(tmcl:card-max, 0, 1); has-occurrence(tmcl:regexp, 0, 1); plays-role(tmcl:constraint, tmcl:constrained-construct, 1, 1). # TOPIC NAME CONSTRAINT tmcl:topic-name-constraint ako tmcl:constraint; - "Topic name constraint"; has-occurrence(tmcl:card-min, 0, 1); has-occurrence(tmcl:card-max, 0, 1); plays-role(tmcl:constraint, tmcl:constrained-topic-type, 1, 1); plays-role(tmcl:constraint, tmcl:constrained-statement, 1, 1). # VARIANT NAME CONSTRAINT tmcl:variant-name-constraint ako tmcl:constraint; - "Variant name constraint"; has-occurrence(tmcl:card-min, 0, 1); has-occurrence(tmcl:card-max, 0, 1); plays-role(tmcl:constraint, tmcl:constrained-topic-type, 1, 1); plays-role(tmcl:constraint, tmcl:constrained-statement, 1, 1); plays-role(tmcl:constraint, tmcl:required-scope, 1, 1). # TOPIC OCCURRENCE CONSTRAINT tmcl:topic-occurrence-constraint ako tmcl:constraint; - "Topic occurrence constraint"; has-occurrence(tmcl:card-min, 0, 1); has-occurrence(tmcl:card-max, 0, 1); plays-role(tmcl:constraint, tmcl:constrained-topic-type, 1, 1); plays-role(tmcl:constraint, tmcl:constrained-statement, 1, 1). # ROLE PLAYER CONSTRAINT tmcl:topic-role-constraint ako tmcl:constraint; - "Topic role constraint"; has-occurrence(tmcl:card-min, 0, 1); has-occurrence(tmcl:card-max, 0, 1); plays-role(tmcl:constraint, tmcl:constrained-statement, 1, 1); plays-role(tmcl:constraint, tmcl:constrained-role, 1, 1); plays-role(tmcl:constraint, tmcl:constrained-topic-type, 1, 1). # SCOPE CONSTRAINT tmcl:scope-constraint ako tmcl:constraint; - "Scope constraint"; has-occurrence(tmcl:card-min, 0, 1); has-occurrence(tmcl:card-max, 0, 1); plays-role(tmcl:constraint, tmcl:constrained-statement, 1, 1); plays-role(tmcl:allows, tmcl:allowed-scope, 1, 1). # SCOPE REQUIRED CONSTRAINT tmcl:scope-required-constraint ako tmcl:constraint; - "Scope required constraint"; has-occurrence(tmcl:card-min, 0, 1); has-occurrence(tmcl:card-max, 0, 1); plays-role(tmcl:constraint, tmcl:constrained-topic-type, 1, 1); plays-role(tmcl:constraint, tmcl:constrained-statement, 1, 1); plays-role(tmcl:requires, tmcl:required-scope, 1, 1). # REIFIER CONSTRAINT tmcl:reifier-constraint ako tmcl:constraint; - "Reifier constraint"; has-occurrence(tmcl:card-min, 0, 1); has-occurrence(tmcl:card-max, 0, 1); plays-role(tmcl:constraint, tmcl:constrained-construct, 1, 1); plays-role(tmcl:allows, tmcl:allowed-reifier, 1, 1). # TOPIC REIFIES CONSTRAINT tmcl:topic-reifies-constraint ako tmcl:constraint; - "Topic reifies constraint"; has-occurrence(tmcl:card-min, 0, 1); has-occurrence(tmcl:card-max, 0, 1); plays-role(tmcl:constraint, tmcl:constrained-topic-type, 1, 1); plays-role(tmcl:constraint, tmcl:constrained-construct, 0, 1). # ASSOCIATION ROLE CONSTRAINT tmcl:association-role-constraint ako tmcl:constraint; - "Association role constraint"; has-occurrence(tmcl:card-min, 0, 1); has-occurrence(tmcl:card-max, 0, 1); plays-role(tmcl:constraint, tmcl:constrained-statement, 1, 1); plays-role(tmcl:constraint, tmcl:constrained-role, 1, 1). # ROLE COMBINATION CONSTRAINT tmcl:role-combination-constraint ako tmcl:constraint; - "Role combination constraint"; plays-role(tmcl:constraint, tmcl:constrained-statement, 1, 1); plays-role(tmcl:constraint, tmcl:constrained-role, 1, 1); plays-role(tmcl:constraint, tmcl:constrained-topic-type, 1, 1); plays-role(tmcl:constraint, tmcl:other-constrained-role, 1, 1); plays-role(tmcl:constraint, tmcl:other-constrained-topic-type, 1, 1). # OCCURRENCE DATATYPE CONSTRAINT tmcl:occurrence-datatype-constraint ako tmcl:constraint; - "Occurrence datatype constraint"; has-occurrence(tmcl:datatype, 1, 1); plays-role(tmcl:constraint, tmcl:constrained-statement, 1, 1). tmcl:datatype isa tmcl:occurrence-type; - "Datatype"; has-datatype(xsd:anyURI). # UNIQUE VALUE CONSTRAINT tmcl:unique-value-constraint ako tmcl:constraint; - "Unique value constraint"; plays-role(tmcl:constraint, tmcl:constrained-statement, 1, 1). # REGULAR EXPRESSION CONSTRAINT tmcl:regular-expression-constraint ako tmcl:constraint; - "Regular expression constraint"; has-occurrence(tmcl:regexp, 1, 1); plays-role(tmcl:constraint, tmcl:constrained-statement, 1, 1). # CONSTRAINED TOPIC TYPE tmcl:constrained-topic-type isa tmcl:association-type; - "Constrained topic type"; has-role(tmcl:constraint, 1, 1); has-role(tmcl:constrained, 1, 1). tmcl:constrained isa tmcl:role-type; - "Constrained". # CONSTRAINED STATEMENT tmcl:constrained-statement isa tmcl:association-type; - "Constrained statement"; has-role(tmcl:constraint, 1, 1); has-role(tmcl:constrained, 1, 1); role-combination(tmcl:constraint, tmcl:topic-name-constraint, tmcl:constrained, tmcl:name-type); role-combination(tmcl:constraint, tmcl:topic-occurrence-constraint, tmcl:constrained, tmcl:occurrence-type); role-combination(tmcl:constraint, tmcl:topic-role-constraint, tmcl:constrained, tmcl:role-type); role-combination(tmcl:constraint, tmcl:occurrence-datatype-constraint, tmcl:constrained, tmcl:occurrence-type); role-combination(tmcl:constraint, tmcl:association-role-constraint, tmcl:constrained, tmcl:association-type); role-combination(tmcl:constraint, tmcl:role-combination-constraint, tmcl:constrained, tmcl:association-type); role-combination(tmcl:constraint, tmcl:unique-value-constraint, tmcl:constrained, tmcl:name-type); role-combination(tmcl:constraint, tmcl:unique-value-constraint, tmcl:constrained, tmcl:occurrence-type); role-combination(tmcl:constraint, tmcl:regular-expression-constraint, tmcl:constrained, tmcl:name-type); role-combination(tmcl:constraint, tmcl:regular-expression-constraint, tmcl:constrained, tmcl:occurrence-type); role-combination(tmcl:constraint, tmcl:scope-constraint, tmcl:constrained, tmcl:name-type); role-combination(tmcl:constraint, tmcl:scope-constraint, tmcl:constrained, tmcl:occurrence-type); role-combination(tmcl:constraint, tmcl:scope-constraint, tmcl:constrained, tmcl:association-type); role-combination(tmcl:constraint, tmcl:scope-required-constraint, tmcl:constrained, tmcl:name-type); role-combination(tmcl:constraint, tmcl:scope-required-constraint, tmcl:constrained, tmcl:occurrence-type); role-combination(tmcl:constraint, tmcl:scope-required-constraint, tmcl:constrained, tmcl:association-type). # CONSTRAINED CONSTRUCT tmcl:constrained-construct isa tmcl:association-type; - "Constrained construct"; has-role(tmcl:constraint, 1, 1); has-role(tmcl:constrained, 1, 1). # CONSTRAINED ROLE tmcl:constrained-role isa tmcl:association-type; - "Constrained role"; has-role(tmcl:constraint, 1, 1); has-role(tmcl:constrained, 1, 1). # OVERLAPS tmcl:overlaps isa tmcl:association-type; - "Overlaps"; has-role(tmcl:allows, 1, 1); has-role(tmcl:allowed, 1, 1). tmcl:allows isa tmcl:role-type; - "Allows". tmcl:allowed isa tmcl:role-type; - "Allowed". # OTHER CONSTRAINED ROLE tmcl:other-constrained-role isa tmcl:association-type; - "Other constrained role"; has-role(tmcl:constraint, 1, 1); has-role(tmcl:constrained, 1, 1). # OTHER CONSTRAINED TOPIC TYPE tmcl:other-constrained-topic-type isa tmcl:association-type; - "Other constrained topic type"; has-role(tmcl:constraint, 1, 1); has-role(tmcl:constrained, 1, 1). # ALLOWED SCOPE tmcl:allowed-scope isa tmcl:association-type; - "Allowed scope"; has-role(tmcl:allows, 1, 1); has-role(tmcl:allowed, 1, 1). # REQUIRED SCOPE tmcl:required-scope isa tmcl:association-type; - "Required scope"; has-role(tmcl:requires, 1, 1); has-role(tmcl:required, 1, 1). tmcl:requires isa tmcl:role-type; - "Requires". tmcl:required isa tmcl:role-type; - "Required". # ALLOWED REIFIER tmcl:allowed-reifier isa tmcl:association-type; - "Allowed reifier"; has-role(tmcl:allows, 1, 1); has-role(tmcl:allowed, 1, 1). # USER-DEFINED CONSTRAINT tmcl:user-defined-constraint ako tmcl:constraint; - "User-defined constraint"; is-abstract(); has-occurrence(tmcl:validation-expression, 1, 1). tmcl:validation-expression isa tmcl:occurrence-type; - "Validation expression"; has-datatype(xsd:string). # DENIAL CONSTRAINT tmcl:denial-constraint ako tmcl:user-defined-constraint; - "Denial constraint". # REQUIREMENT CONSTRAINT tmcl:requirement-constraint ako tmcl:user-defined-constraint; - "Requirement constraint". # SCHEMA tmcl:schema isa tmcl:topic-type; - "TMCL schema"; has-occurrence(tmcl:version, 0, 1); has-occurrence(tmcl:description, 0, 1); has-occurrence(tmcl:comment, 0, *); has-occurrence(tmcl:see-also, 0, *); has-occurrence(tmcl:schema-resource, 0, *); plays-role(tmcl:container, tmcl:belongs-to, 0, *); plays-role(tmcl:used, tmcl:uses-schema, 0, *); plays-role(tmcl:container, tmcl:includes-schema, 0, *); plays-role(tmcl:containee, tmcl:includes-schema, 0, *). tmcl:belongs-to isa tmcl:association-type; - "Belongs to"; - "Contains" @tmcl:container; has-role(tmcl:containee, 1, 1); has-role(tmcl:container, 1, 1). tmcl:includes-schema isa tmcl:association-type; - "Includes schema"; - "Included in schema" @tmcl:containee; has-role(tmcl:containee, 1, 1); has-role(tmcl:container, 1, 1). tmcl:containee isa tmcl:role-type; - "Containee". tmcl:container isa tmcl:role-type; - "Container". # VERSION tmcl:version isa tmcl:occurrence-type; - "Version"; has-datatype(xsd:string). # DESCRIPTION tmcl:description isa tmcl:occurrence-type; - "Description"; has-datatype(xsd:string). # SCHEMA RESOURCE tmcl:schema-resource isa tmcl:occurrence-type; - "Schema resource"; has-datatype(xsd:anyURI). # COMMENT tmcl:comment isa tmcl:occurrence-type; - "Comment"; has-datatype(xsd:string). # SEE-ALSO tmcl:see-also isa tmcl:occurrence-type; - "See also"; has-datatype(xsd:anyURI). # TOPIC MAP tmcl:topic-map isa tmcl:topic-type; - "Topic map"; has-role(tmcl:user, 0, *). tmcl:uses-schema isa tmcl:association-type; - "Uses schema"; - "Schema used by" @user; has-role(tmcl:user, 1, 1); has-role(tmcl:used, 1, 1). tmcl:user isa tmcl:role-type; - "User". tmcl:used isa tmcl:role-type; - "Used". |