Topic Maps Constraint Language

Contents

1 Scope
2 Normative references
3   Notation and Conventions
3.1   Notation and Syntax
3.2   Formal Semantics
4   TMCL
4.1   Validation Semantics
4.2   TMCL Schema
4.2.1   The TMCL MetaModel
4.2.2   TMCL Schema
4.2.3   IsAbstract Constraint
4.2.4   Disjoint Constraint
4.2.5   Subject Identifier Constraint
4.2.6   Subject Locator Constraint
4.2.7   TopicName Constraint
4.2.8   NameTypeScope Constraint
4.2.9   OccurrenceTypeScope Constraint
4.2.10   OccurrenceTypeScope Constraint
4.2.11   VariantName Constraint
4.2.12   Occurrence Type Constraint
4.2.13   Topic Occurrence Constraint
4.2.14   AssociationRole Constraint
4.2.15   RolePlayer Constraint
4.2.16   OtherRole Constraint
4.2.17   UniqueRole Constraint
4.2.18   UniqueOccurrence Constraint
5   TMCL-Rule
5.1   RuleItem
5.2   AssertItem
6   Conflict Items
6.1   ConflictItem
7   Topic Map Schema References
8   Schema Composition

Foreword

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 N458 was prepared by Joint Technical Committee ISO/IEC JTC 1, Information Technology, Subcommittee SC 34, Document Description and Processing Languages.

Introduction

This International Standard defines a means to express constraints on topic maps conforming to the Topic Map Data Model [TMDM].

Topic Maps Constraint Language

1 Scope

This International Standard is designed to allow the expression of constraints on instances of the topic map data model. This International Standard defines TMCL-Schema and TMCL-Rule. TMCL-Schema provides a type based model of constraints. TMCL-Rule provides a generalized model of constraints based on TMQL[TMQL]. TMQL is used as a means to identify the topic map constructs to be constrained and to define the topic map structures that must exist in order for constraints to be valid.

This International Standard defines a model for representing constraints and the formal semantics for the interpretation of the different constraint structures. It also defines a syntactic form that can be used to represent the model structures.

2 Normative references

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.

NOTE:

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.

Unicode, The Unicode Standard, Version 4.0, The Unicode Consortium, Boston, MA, USA, Addison-Wesley , 2003, ISBN 0-321-18578-1

TMDM, ISO 13250-2 Topic Maps — Data Model, ISO, 2005, http://www.isotopicmaps.org/sam/sam-model/

TMQL, ISO Topic Maps Query Language Working Draft, ISO, 2005, http://www.isotopicmaps.org/tmql/

CTM, ISO Compact Topic Map Notation Working Draft, ISO, 2006, http://www.isotopicmaps.org/ctm/

XML 1.0, Extensible Markup Language (XML) 1.0, W3C, Third Edition, W3C Recommendation, 04 February 2004, http://www.w3.org/TR/REC-xml/

RFC3986, RFC 3986 - Uniform Resource Identifiers (URI): Generic Syntax, The Internet Society, 2005, http://www.ietf.org/rfc/rfc3986.txt

RFC3987, RFC 3987 - Internationalized Resource Identifiers (IRIs), The Internet Society, 2005, http://www.ietf.org/rfc/rfc3987.txt

3 Notation and Conventions

3.1 Notation and Syntax

As TMCL constraints are represented and evaluated as topic map structures this International Standard adopts TMDM as the formalism for representing the TMCL Schema model.

3.2 Formal Semantics

The representation of TMCL Schema is expressed in terms of TMDM.

The formal interpretation of TMCL is defined in terms of TMQL. TMQL is in turn grounded on both the TMRM and the related path model.

4 TMCL

TMCL defines TMCL Schema and TMCL Rule. TMCL Schema provides a type-based model of constraints. TMCL Rule provides a generalized model of constraints that utilizes TMQL.

Both TMCL Rule and TMCL Schema define sets of constraints. These constraints consist of terms that identify parts of the Topic Map to be constrained and terms that define the predicates that must hold true for a topicmap to be considered valid.

TMCL Schema and TMCL Rule use different sub-languages for describing constraints. TMCL Schema defines a model and intepretation for describing constraints while TMCL Rule defines constraints in a form of "if ... then ..." rules. Both sub-languages can be combined in a schema.

4.1 Validation Semantics

TMCL-Rule and TMCL-Schema are used to constrain instances of the Topic Map Data Model. If a given topic map is valid in respect to a given set of constraints, then validation is said to have succeeded. More formally it can be said that :

Given:
  TopicMap: t
  Schema  : s
Then:
  Validate(t, s) => (true)  | (false, conflictItem+)
  

Conflict items are items that reference the constraints which were not valid with respect to the processed topic map. Conflict items can be interpreted by implementations as warnings or errors depending on the application.

NOTE: 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.

4.2 TMCL Schema

TMCL Schema defines a language for constraining instances of topic, association, name and occurrence types. TMCL Schema defines a model for defining constraint types and an interpretation of instances of those types. The interpretation indicates in an unambiguous fashion what it means for that constraint class to be evaluated in the context of a TMDM instance. The result of the evaluation of any given constraint is either true, or false with ConflictItems.

The TMCL schema data model is defined in terms of the topic map data model, and expressed in this document by CTM expressions. Each constraint type is represented using the topic map notation and described in prose. The formal interpretation of each constraint type is defined in terms of TMQL.

4.2.1 The TMCL MetaModel

In order to make use of TMQL all constraint types need to be able to be expressed using the TMDM. In order to support this this International Standard defines some meta model topics. This section lists these topics, without expressing anything about their use or interpretation. The semantics of these topics is expressed as part of the interpretation of each constraint type.

TopicType

The topic TopicType has the following subject identifier http://psi.isotopicmaps.org/tmcl/topictype. It has the following representation using the CTM notation:

        topictype 
			sid: http://psi.isotopicmaps.org/tmcl/topictype .
      

OccurrenceType

The topic OccurrenceType has the following subject identifier http://psi.isotopicmaps.org/tmcl/occurrencetype. It has the following representation using the CTM notation:
        occurrencetype 
			sid: http://psi.isotopicmaps.org/tmcl/occurrencetype .
      

AssociationType

The topic AssociationType has the following subject identifier http://psi.isotopicmaps.org/tmcl/associationtype. It has the following representation using the CTM notation:

        associationtype 
			sid: http://psi.isotopicmaps.org/tmcl/associationtype .
      

AssociationRoleType

The topic AssociationType has the following subject identifier http://psi.isotopicmaps.org/tmcl/associationroletype. It has the following representation using the CTM notation:
        
        associationroletype 
			sid: http://psi.isotopicmaps.org/tmcl/associationroletype .
      

Constraint

The topic Constraint has the following subject identifier http://psi.isotopicmaps.org/tmcl/constraint. It has the following representation using the CTM notation:
        
        constraint 
			isa topictype 
			sid: http://psi.isotopicmaps.org/tmcl/constraint .
      

DisjointConstraint

The topic DisjointConstraint has the following subject identifier http://psi.isotopicmaps.org/tmcl/disjointconstraint. It has the following representation using the CTM notation:
        
        disjointconstraint 
			sid: "http://psi.isotopicmaps.org/tmcl/disjointconstraint" .
      

DisjointConstraintIncludesType

The topic DisjointConstraintIncludesType has the following subject identifier http://psi.isotopicmaps.org/tmcl/disjointconstraintincludestype. It has the following representation using the CTM notation:
        
        djc_includes_type 
			isa associationtype
			sid: http://psi.isotopicmaps.org/tmcl/disjointconstraintincludestype .
      

DisjointConstraintIncludesType_ConstraintRole

The topic DisjointConstraintIncludesType_ConstraintRole has the following subject identifier http://psi.isotopicmaps.org/tmcl/disjointconstraintincludestype/constraint. It has the following representation using the CTM notation:
        
        djc_includes_type_constraintrole 
			isa associationroletype
			sid: http://psi.isotopicmaps.org/tmcl/disjointconstraintincludestype/constraintrole .
      

DisjointConstraintIncludesType_TypeRole

The topic DisjointConstraintIncludesType_TypeRole has the following subject identifier http://psi.isotopicmaps.org/tmcl/disjointconstraintincludestype/type. It has the following representation using the CTM notation:
          
         djc_includes_type_typerole 
			isa associationroletype
			sid: http://psi.isotopicmaps.org/tmcl/disjointconstraintincludestype/typerole .
        

TopicNameConstraint

The topic TopicNameConstraint has the following subject identifier http://psi.isotopicmaps.org/tmcl/topicnameconstraint. It has the following representation using the CTM notation:
        
        topicnameconstraint 
			sid: http://psi.isotopicmaps.org/tmcl/topicnameconstraint .
      

MinCardinalityFacet

The topic MinCardinalityFacet has the following subject identifier http://psi.isotopicmaps.org/tmcl/facet/mincardinality. It has the following representation using the CTM notation:
        
        mincardinalityfacet 
			isa occurrencetype 
			sid: http://psi.isotopicmaps.org/tmcl/facet/mincardinalityfacet .
      

MaxCardinalityFacet

The topic MaxCardinalityFacet has the following subject identifier http://psi.isotopicmaps.org/tmcl/facet/maxcardinality. It has the following representation using the CTM notation:
        
        maxcardinalityfacet 
			isa occurrencetype 
			sid: http://psi.isotopicmaps.org/tmcl/facet/maxcardinalityfacet .
      

ConstraintAppliesToTopicType

The topic ConstraintAppliesToTopicType has the following subject identifier http://psi.isotopicmaps.org/tmcl/constraintappliestotopictype. It has the following representation using the CTM notation:
        
        constraintappliestotopictype 
			isa associationtype 
			sid: http://psi.isotopicmaps.org/tmcl/constraintappliestotopictype .
      

ConstraintAppliesToTopicType_ConstraintRole

The topic ConstraintAppliesToTopicType_ConstraintRole has the following subject identifier http://psi.isotopicmaps.org/tmcl/constraintappliestotopictype/constraintrole. It has the following representation using the CTM notation:
        
        constraintappliestotopic_constraintrole 
			isa associationroletype 
			sid: http://psi.isotopicmaps.org/tmcl/constraintappliestotopic/constraintrole .
      

ConstraintAppliesToTopicType_TopicRole

The topic ConstraintAppliesToTopicType has the following subject identifier http://psi.isotopicmaps.org/tmcl/constraintappliestotopictype. It has the following representation using the CTM notation:
        
        constraintappliestotopic_topictyperole
			isa associationroletype
			sid: http://psi.isotopicmaps.org/tmcl/constraintappliestotopic/topictyperole .
      

ConstraintHasScopeTypeContext

The topic ConstraintHasScopeTypeContext has the following subject identifier http://psi.isotopicmaps.org/tmcl/constrainthasscopetypecontext. It has the following representation using the CTM notation:
        
        constrainthasscopetypecontext 
			isa associationtype
			sid: http://psi.isotopicmaps.org/tmcl/constrainthasscopetypecontext .
      

ConstraintHasScopeTypeContext_ScopeTypeRole

The topic ConstraintHasScopeTypeContext_ScopeTypeRole has the following subject identifier http://psi.isotopicmaps.org/tmcl/constrainthasscopetypecontext_scopetyperole. It has the following representation using the CTM notation:
        
		constrainthasscopetypecontext_scopetyperole
			isa associationroletype
			slo: http://psi.isotopicmaps.org/tmcl/constrainthasscopetypecontext_scopetyperole .
      

ConstraintHasScopeTypeContext_ConstraintRole

The topic ConstraintHasScopeTypeContext_ConstraintRole has the following subject identifier http://psi.isotopicmaps.org/tmcl/constrainthasscopetypecontext_constraintrole. It has the following representation using the CTM notation:
        
        constrainthasscopetypecontext_constraintrole
			isa associationroletype
			sid: http://psi.isotopicmaps.org/tmcl/constrainthasscopetypecontext_constraintrole
      

ConstraintHasScopingTopicContext

The topic ConstraintHasScopingTopicContext has the following subject identifier http://psi.isotopicmaps.org/tmcl/constrainthasscopingtopiccontext. It has the following representation using the CTM notation:
        
        constrainthasscopingtopiccontext
			isa associationtype
			sid: http://psi.isotopicmaps.org/tmcl/constrainthasscopingtopiccontext .
      

ConstraintHasScopingTopicContextConstraintRole

The topic ConstraintHasScopingTopicContextConstraintRole has the following subject identifier http://psi.isotopicmaps.org/tmcl/constrainthasscopingtopiccontext_constraintrole. It has the following representation using the CTM notation:
        
        constrainthasscopingtopiccontext_constraintrole
			isa associationroletype
			sid: http://psi.isotopicmaps.org/tmcl/constrainthasscopingtopiccontext_constraintrole .
      

ConstraintHasScopingTopicContextScopingTopicRole

The topic ConstraintHasScopingTopicContextScopingTopicRole has the following subject identifier http://psi.isotopicmaps.org/tmcl/constrainthasscopingtopiccontext_scopingtopicrole. It has the following representation using the CTM notation:
        
        constrainthasscopingtopiccontext_scopingtopicrole
			isa associationroletype
			sid: http://psi.isotopicmaps.org/tmcl/constrainthasscopingtopiccontext_scopingtopicrole .
      

ConstraintAppliesToNameType

The topic ConstraintAppliesToNameType has the following subject identifier http://psi.isotopicmaps.org/tmcl/constraintappliestonametype. It has the following representation using the CTM notation:
        
        constraintappliestonametype
			isa associationtype 
			sid: http://psi.isotopicmaps.org/tmcl/constraintappliestonametype .
      

ConstraintAppliesToNameType_ConstraintRole

The topic ConstraintAppliesToNameType_ConstraintRole has the following subject identifier http://psi.isotopicmaps.org/tmcl/constraintappliestonametype_constraintrole. It has the following representation using the CTM notation:
        
        constraintappliestonametype_constraintrole
			isa associationtype
			sid: http://psi.isotopicmaps.org/tmcl/constraintappliestonametype_constraintrole .
      

The topic ConstraintAppliesToNameType_NameTypeRole has the following subject identifier http://psi.isotopicmaps.org/tmcl/constraintappliestonametype_nametyperole. It has the following representation using the CTM notation:
        
        constraintappliestonametype_nametyperole 
			isa associationtype
			sid: http://psi.isotopicmaps.org/tmcl/constraintappliestonametype_nametyperole .
      

ValueExpressionFacet

The topic ValueExpressionFacet has the following subject identifier http://psi.isotopicmaps.org/tmcl/facet/valueexpression. It has the following representation using the CTM notation:
        
        valueexpressionfacet
			isa occurrencetype
			sid: http://psi.isotopicmaps.org/tmcl/facet/valueexpressionfacet .
      

IsAbstract

The topic IsAbstract has the following subject identifier http://psi.isotopicmaps.org/tmcl/isabstract. It has the following representation using the CTM notation:
        
        isabstract
			isa occurrencetype
			sid: http://psi.isotopicmaps.org/tmcl/isabstract .
      

AllowedDataType

The topic AllowedDataType has the following subject identifier http://psi.isotopicmaps.org/tmcl/alloweddatatype. It has the following representation using the CTM notation:
        
        alloweddatatype
			isa occurrencetype
			sid: http://psi.isotopicmaps.org/tmcl/alloweddatatype .
      

4.2.2 TMCL Schema

A schema is a collection of constraint topics. A constraint topic is a topic that is an instance of the constraint topic type. The following sections define the constraint types, the related topic map representation and the related formal semantics.

4.2.3 IsAbstract Constraint

The isabstract constraint type provides a way to express that a given topic type must not have any instances.

  1. [atype] : Topic. The topic type that is being defined as abstract.

  2. [isabstract] : string. A value of 'true' indicates that this type is abstract.

The Topic Map representation of this constraint is as follows:
        ATYPE isa topictype 
              isabstract 'true'.
      

Using the topic map representation above, the interpretation of this constraint is as follows:
        (count($X) where (ATYPE isa topictype, atype[isabstract = 'true'], $X isa ATYPE) == 0) => true        
      

The CTM template for this constraint is defined as follows:
		  ctm:template isabstract(atype) =>
			atype isa topictype
				  isabstract 'true' .
	  

4.2.4 Disjoint Constraint

A disjoint constraint provides a way to express that a topic can only be an instance of one of the referenced types..

  1. [atype] : Topic. One of the types of which instances must be disjoint.

  2. [btype] : Topic. One of the types of which instances must be disjoint.

The Topic Map representation of instances of this constraint type is as follows:
		  djc isa disjointconstraint

		  djc_includes_type(djc   : djc_includes_type_constraintrole,
							ATYPE : djc_includes_type_typerole)

	      djc_includes_type(djc   : djc_includes_type_constraintrole,
						    BTYPE : djc_includes_type_typerole)
	  

Using the topic map representation above, the interpretation of this constraint is as follows:
        (fn:count(select $x where $x isa ATYPE & $y isa BTYPE & $x=$y) == 0) => true                   
      

The CTM template for this constraint is defined as follows:
		ctm:template disjointCostraint(atype, btype) =>
			djc isa disjointconstraint

			djc_includes_type(djc   : djc_includes_type_constraintrole,
			                  atype : jc_includes_type_typerole)

			djc_includes_type(djc   : djc_includes_type_constraintrole,
			                  btype : jc_includes_type_typerole)
		end
	  
The example usage is as follows:
		  
		  disjointConstraint(atype, btype)
	  

4.2.5 Subject Identifier Constraint

A subject identifier constraint provides a way to constrain the shape and number of topic subject identifiers.

  1. [type] : Topic. The topic type to which this constraint applies.

  2. [cardmin] : Integrer. The mininum allowed number of identifiers

  3. [cardmax] : Integrer. The maximum allowed number of identifiers

  4. [identifiervaluepattern] : RegularExpression. A regular expression that must match the resource value of the subject identifier.

The Topic Map representation of instances of this constraint type is as follows:
				sic isa subjectidentifierconstraint
				mincardinalityfacet: CMIN
				maxcardinalityfacet: CMAX
				identifiervaluepattern: REGEXP

				sic_constrains_type(SIC   : sic_constrains_type_constraintrole,
				ATYPE : sic_constraint_type_typerole)
			

Using the topic map representation above, the interpretation of this constraint is as follows:
				(
					(fn:count(							 
						select $t where $t isa ATYPE & (fn:regexp(identifiervaluepattern, $t / indicators) = 1)									)
					>= CMIN)
				&
					(fn:count(
						select $t where $t isa ATYPE & (fn:regexp(identifiervaluepattern, $t / indicators) = 1)
					) <= CMAX)
				)
				=> true
			

The syntax for this constraint is defined as a CTM template:
				ctm:template subjectIdentifierConstraint(atype, cmin, cmax, regexp) =>
				sic isa subjectidentifierconstraint

				sic
					mincardinalityfacet: cmin
					maxcardinalityfacet: cmax
					valueexp: regexp

				sic_constrains_type(SIC   : sic_constrains_type_constraintrole,
									ATYPE : sic_constraint_type_typerole)
			
The example usage is as follows:
				subjectIdentifierConstraint(atype, 1, 1, '*')								
			

4.2.6 Subject Locator Constraint

A subject locator constraint provides a way to constrain the shape and number of topic subject locators.

  1. [type] : Topic. The topic type to which this constraint applies.

  2. [cardmin] : Integrer. The mininum allowed number of identifiers

  3. [cardmax] : Integrer. The maximum allowed number of identifiers

  4. [identifiervaluepattern] : RegularExpression. A regular expression that must match the resource value of the subject identifier.

The Topic Map representation of instances of this constraint type is as follows:
				sic isa subjectlocatorconstraint
				mincardinalityfacet: CMIN
				maxcardinalityfacet: CMAX
				identifiervaluepattern: REGEXP

				slc_constrains_type(SIC   : slc_constrains_type_constraintrole,
				ATYPE : slc_constraint_type_typerole)
			

Using the topic map representation above, the interpretation of this constraint is as follows:
				(
					(fn:count(
						select $t where $t isa ATYPE & (fn:regexp(identifiervaluepattern, $t / locators) = 1)									)
					>= CMIN)
					&
					(fn:count(
						select $t where $t isa ATYPE & (fn:regexp(identifiervaluepattern, $t / locators) = 1)
					) <= CMAX)
				)
				=> true
		

The syntax for this constraint is defined as a CTM template:
			ctm:template subjectLocatorConstraint(atype, cmin, cmax, regexp) =>
			sic isa subjectlocatorconstraint

			sic
			mincardinalityfacet: cmin
			maxcardinalityfacet: cmax
			valueexp: regexp

			sic_constrains_type(SIC   : slc_constrains_type_constraintrole,
			ATYPE : slc_constraint_type_typerole)
		
The example usage is as follows:
			subjectLocatorConstraint(atype, 1, 1, '*')
		

4.2.7 TopicName Constraint

A topicname constraint provides a way to constrain the type and cardinality of topic names for instances of a given topic type.

  1. [type] : Topic. The topic type to which this constraint applies.

  2. [nametype] : Topic. The expected nametype of valid names.

  3. [cardmin] : An integer. The expected minimum number of names on a topic that is allowed to match this pattern.

  4. [cardmax] : An integer. The expected maximum number of names on a topic that is allowed to match this pattern.

The TMDM representation of instances of this constraint type is as follows:
			tnc isa topicnameconstraint
			mincardinalityfacet: CARDMIN
			maxcardinalityfacet: CARDMAX

			tncappliestonametype(tnc : tncappliestonametype_constraintrole,
			NAMETYPE : tncappliestonametype_nametype)

			constraintappliestotopictype(tnc        : constraintappliestotopictype_constraintrole,
			ATYPE      : constraintappliestotopictype_topictyperole)

		

Using the topic map representations above, the interpretations of this constraint is as follows:
			(
			(fn:count(
			select $t where $t isa ATYPE & (fn:regexp(identifiervaluepattern, $t / bn / NAMETYPE) = 1)									)
			>= CMIN)
			&
			(fn:count(
			select $t where $t isa ATYPE & (fn:regexp(identifiervaluepattern, $t / bn / NAMETYPE) = 1)
			) <= CMAX)
			)
			=> true
	  

The syntax for this constraint is defined as a CTM template:

			ctm:template topicNameConstraint(topictype, nametype, cmin, cmax) =>
				tnc isa topicnameconstraint
					mincardinalityfacet: cmin
					maxcardinalityfacet: cmax

				tncappliestonametype(tnc : tncappliestonametype_constraintrole,
				nametype : tncappliestonametype_nametype)

				constraintappliestotopictype(tnc        : constraintappliestotopictype_constraintrole,
				topictype  : constraintappliestotopictype_topictyperole)
		
The example usage is as follows:
			topicNameConstraint(person, surname, 1, 1)
		

4.2.8 NameTypeScope Constraint

A nametypescope constraint provides a way to constrain the allowed scoping topics for a name of a given type.

  1. [nametype] : Topic. The name type to which this constraint applies.

  2. [scopetopictype] : Topic. A topictype, instances of which can be in the scope of topic names of the given name type.

  3. [cardmin] : An integer. The expected minimum number of topics of the specified type expected to be found on topic names of the given name type.

  4. [cardmax] : An integer. The expected maximum number of topics of the specified type expected to be found on topic names of the given name type.

The TMDM representation of instances of this constraint type is as follows:
				tnsc isa topicnamescopeconstraint
					mincardinalityfacet: CARDMIN
					maxcardinalityfacet: CARDMAX

					tnscappliestonametype(tnc : tnscappliestonametype_constraintrole,
										  NAMETYPE : tnscappliestonametype_nametype)

					constraintappliestotopictype(tnc        : constraintappliestotopictype_constraintrole,
												 ATYPE      : constraintappliestotopictype_topictyperole)

			

Using the topic map representation above, the interpretation of this constraint is as follows:
				(
				(fn:count(
				select $t where $t isa ATYPE & $p / bn / NAMETYPE @ $t)
				) >= CMIN)
				&
				(fn:count(
				select $t where $t isa ATYPE & $p / bn / NAMETYPE @ $t)
				) <= CMAX)
				)
				=> true
			

The syntax for this constraint is defined as a CTM template:

				ctm:template topicNameScopeConstraint(nametype, scopetype, cmin, cmax) =>
				tnsc isa topicnamescopeconstraint
					mincardinalityfacet: CARDMIN
					maxcardinalityfacet: CARDMAX

					tnscappliestonametype(tnc : tnscappliestonametype_constraintrole,
										  nametype : tnscappliestonametype_nametype)

					constraintappliestotopictype(tnc        : constraintappliestotopictype_constraintrole,
												 scopetype      : constraintappliestotopictype_topictyperole)
			
The example usage is as follows:
				nameTypeScopeConstraint(displayName, language, 0, 1)
			

4.2.9 OccurrenceTypeScope Constraint

A occurrencetypescope constraint provides a way to constrain the allowed scoping topics for an occurrence of a given type.

  1. [occurrencetype] : Topic. The occurrence type to which this constraint applies.

  2. [scopetopictype] : Topic. A topictype, instances of which can be in the scope of topic occurrences of the given occurrence type.

  3. [cardmin] : An integer. The expected minimum number of topics of the specified type expected to be found on topic occurrences of the given occurrence type.

  4. [cardmax] : An integer. The expected maximum number of topics of the specified type expected to be found on topic occurrences of the given occurrence type.

The TMDM representation of instances of this constraint type is as follows:
				tnsc isa topicoccurrencescopeconstraint
					mincardinalityfacet: CARDMIN
					maxcardinalityfacet: CARDMAX

				tnoscappliestooccurrencetype(tnc : tnoscappliestooccurrencetype_constraintrole,
											 OCTYPE : tnoscappliestooccurrencetype_nametype)

				constraintappliestotopictype(tnc        : constraintappliestotopictype_constraintrole,
											 ATYPE      : constraintappliestotopictype_topictyperole)

			

Using the topic map representation above, the interpretation of this constraint is as follows:
				(
				(fn:count(
					select $s in // OCTYPE [ ^ tm:occurrence ] @ where $s isa ATYPE
				) >= CMIN)
				&
				(fn:count(
					select $s in // OCTYPE [ ^ tm:occurrence ] @ where $s isa ATYPE
				) <= CMAX)
				)
				=> true
			

The syntax for this constraint is defined as a CTM template:

				ctm:template topicOccurrenceScopeConstraint(occurrencetype, scopetype, cmin, cmax) =>
				tnsc isa topicoccurrencescopeconstraint
					mincardinalityfacet: CARDMIN
					maxcardinalityfacet: CARDMAX

				tnoscappliestooccurrencetype(tnc : tnoscappliestooccurrencetype_constraintrole,
											 occurrencetype : tnoscappliestooccurrencetype_nametype)

				constraintappliestotopictype(tnc        : constraintappliestotopictype_constraintrole,
											 scopetype      : constraintappliestotopictype_topictyperole)
			
The example usage is as follows:
				occurrenceTypeScopeConstraint(content_reference, security_level, 1, 1)
			

4.2.10 OccurrenceTypeScope Constraint

A associationtypescope constraint provides a way to constrain the allowed scoping topics for an association of a given type.

  1. [associationtype] : Topic. The association type to which this constraint applies.

  2. [scopetopictype] : Topic. A topictype, instances of which can be in the scope of associations of the given association type.

  3. [cardmin] : An integer. The expected minimum number of topics of the specified type expected to be found on associations of the given association type.

  4. [cardmax] : An integer. The expected maximum number of topics of the specified type expected to be found on associations of the given association type.

The TMDM representation of instances of this constraint type is as follows:
				atsc isa associationtypescopeconstraint
					mincardinalityfacet: CARDMIN
					maxcardinalityfacet: CARDMAX

				atscappliestoassociationtype(tnc : atscappliestoassociationtype_constraintrole,
											 ASSOCTYPE : atscappliestoassociationtype_nametype)

				constraintappliestotopictype(tnc        : constraintappliestotopictype_constraintrole,
											 ATYPE      : constraintappliestotopictype_topictyperole)

			

Using the topic map representation above, the interpretation of this constraint is as follows:
				(
				(fn:count(				
					select $s in // ASSOCTYPE [ ^ tm:association ] @ where $s isa ATYPE
				) >= CMIN)
				&
				(fn:count(
					select $s in // ASSOCTYPE [ ^ tm:association ] @ where $s isa ATYPE
				) <= CMAX)
				)
				=> true
			

The syntax for this constraint is defined as a CTM template:

				ctm:template associationTypeScopeConstraint(associationtype, scopetype, cmin, cmax) =>
				
				atsc isa associationtypescopeconstraint
					mincardinalityfacet: CARDMIN
					maxcardinalityfacet: CARDMAX

				atscappliestoassociationtype(tnc : atscappliestoassociationtype_constraintrole,
											 associationtype : atscappliestoassociationtype_nametype)

				constraintappliestotopictype(tnc        : constraintappliestotopictype_constraintrole,
											 scopetype      : constraintappliestotopictype_topictyperole)
			
The example usage is as follows:
				associationTypeScopeConstraint(works_for, timeperiod, 1, 1)
			

4.2.11 VariantName Constraint

A variantname constraint provides a way to constrain the type, cardinality and value of variant names for instances of a name type..

  1. [nametype] : Topic. The name type to which this constraint applies.

  2. [cardmin] : An integer. The minimum number of variant names on a topic name that is allowed to match this pattern.

  3. [cardmax] : An integer. The maximum number of variant names on a topic name that is allowed to match this pattern.

  4. [datatype] : URI. An identifier for the datatype of the variant name value.

  5. [resourcevaluepattern] : RegularExpression. A repexp that must match the resource value of the variant name value.

The TMDM representation of instances of this constraint type is as follows:
			  vnc isa variantnameconstraint
				  mincardinalityfacet: CARDMIN
				  maxcardinalityfacet: CARDMAX
				  datatypevalue: DATATYPE_VALUE
				  resourcevaluepattern: REGEXP

				  vncappliestonametype(vnc : vncappliestonametype_constraintrole,
									   NAMETYPE : vncappliestonametype_nametyperole)

		  

Using the topic map representation above, the interpretation of this constraint is as follows:
		  (
		  (fn:count(				
			select $vname in // topics / name [ NAMETYPE ] / variant
					where ((fn:regexp ($vname / value, resourcevaluepattern) = 1) &
							$vname / datatype = datatypevalue)	   					 				
		  ) >= CMIN)
		  &
		  (fn:count(
		  select $vname in // topics / name [ NAMETYPE ] / variant
					where ((fn:regexp ($vname / value, resourcevaluepattern) = 1) &
							$vname / datatype = datatypevalue)		  ) <= CMAX)
		  )
		  => true
	  

The syntax for this constraint is defined as a CTM template:
			ctm:template variantNameConstraint(nametype, datatype, resourceexp, cmin, cmax) =>

				vnc isa variantnameconstraint
					mincardinalityfacet: cmin
					maxcardinalityfacet: cmax
					datatypevalue: datatype
					resourcevaluepattern: resourceexp

				vncappliestonametype(vnc : vncappliestonametype_constraintrole,
									 nametype : vncappliestonametype_nametyperole)

		
The example usage is as follows:
			variantNameConstraint(displyName, "xsd:uri", "*", 1, 1)
		

4.2.12 Occurrence Type Constraint

An occurrence type constraint provides a way to constrain the allowed datatype of an occurrence type..

  1. [occurrencetype] : Topic. The topic which is an occurrence type.

  2. [datatype] : IRI. An IRI that identifies the allowed datatypes for this occurrence type.

The TMDM representation of instances of this constraint type is as follows:
			otc isa occurrencetypeconstraint
				datatypevalue: DATATYPE_VALUE

			otcappliestooccurrencetype(vnc : otcappliestooccurrencetype_constraintrole,
									   OCTYPE : otcappliestooccurrencetype_nametyperole)
		

Using the topic map representation above, the interpretation of this constraint is as follows:
		  (fn:count(select $o in // OCTYPE [ ^ tm:occurrence ] / datatype != DATATYPE_VALUE) = 0) =>
	  

4.2.13 Topic Occurrence Constraint

A topic occurrence constraint defines a way to constrain the type, cardinality and value of occurrences connected to a topic of a given type.

  1. [type] : Topic. The topic type to which this constraint applies.

  2. [occurrencetype] : Topic. The occurrence type of valid occurrences.

  3. [resourcevaluepattern] : RegularExpression. A regular expression that must match the value of the occurrence.

  4. [cardmin] : An integer. The expected minimum number of names on a topic that is allowed to match this pattern.

  5. [cardmax] : An integer. The expected maximum number of names on a topic that is allowed to match this pattern.

The TMDM representation of instances of this constraint type is as follows:
			  toc isa topicoccurrenceconstraint
				  mincardinalityfacet: CARDMIN
				  maxcardinalityfacet: CARDMAX
				  occurrencevaluepattern: valuepattern

			  tocappliestooccurrencetype(tnc : tncappliestonametype_constraintrole,
										 OCTYPE : tncappliestonametype_nametype)

			  constraintappliestotopictype(tnc        : constraintappliestotopictype_constraintrole,
										   ATYPE      : constraintappliestotopictype_topictyperole)

		  

Using the topic map representations above, the interpretations of this constraint is as follows:
			  (
			  (fn:count(			  
			   select $t in // topics where (fn:regexp ($t / occurrence [ OCTYPE ] / value, valuepattern) = 1) & $t isa ATYPE			  
			  )
			  >= CMIN)
			  &
			  (fn:count(
			  select $t in // topics where (fn:regexp ($t / occurrence [ OCTYPE ] / value, valuepattern) = 1) & $t isa ATYPE
			  ) <= CMAX)
			  )
			  => true
		  

The syntax for this constraint is defined as a CTM template:

			  ctm:template topicOccurrenceConstraint(topictype, occurrencetype, regexp, cmin, cmax) =>
			  toc isa topicoccurrenceconstraint
				  mincardinalityfacet: CARDMIN
				  maxcardinalityfacet: CARDMAX
				  occurrencevaluepattern: regexp

			  tocappliestooccurrencetype(tnc : tncappliestonametype_constraintrole,
										 occurrencetype : tncappliestonametype_nametype)

			  constraintappliestotopictype(tnc        : constraintappliestotopictype_constraintrole,
										   topictype      : constraintappliestotopictype_topictyperole)

		  
The example usage is as follows:
			  topicOccurrenceConstraint(person, email, "*@*", 0, *)
		  

4.2.14 AssociationRole Constraint

A associationrole constraint defines the nature of allowed roles in an association of given a type..

  1. [AssociationType] : Topic. The selector that defines which types of associations are governed by this constraint.

  2. [RoleType] : Topic. The selector that defines which types of association roles are governed by this constraint.

  3. [cardMin] : An integer value.. The minimum allowed number of roles within a given matching this pattern.

  4. [cardMax] : An integer value.. The maximum allowed number of roles matching this pattern.

4.2.15 RolePlayer Constraint

A roleplayer constraint defines a way to constraint the allowed role players of a given role..

  1. [AssociationType] : Topic. The selector that defines which types of associations are governed by this constraint.

  2. [RoleType] : Topic. The selector that defines which types of association roles are governed by this constraint.

  3. [RoleType] : Topic. The selector that defines which types of association roles are governed by this constraint.

  4. [cardMin] : An integer value.. The minimum allowed number of roles within a given matching this pattern.

  5. [cardMax] : An integer value.. The maximum allowed number of roles matching this pattern.

4.2.16 OtherRole Constraint

A otherrole constraint defines a way to constraint the allowed role given the existence of a certain role in an association..

  1. [AssociationType] : Topic.

  2. [RoleType] : Topic.

  3. [OtherRoleType] : Topic.

  4. [cardMin] : An integer value.. The minimum allowed number of other allowed roles within the association.

  5. [cardMax] : An integer value.. The maximum allowed number of other allowed roles within the association.

4.2.17 UniqueRole Constraint

A uniquerole constraint defines a way to constraint that a given topic can only play a certain role once in any given map..

  1. [AssociationType] : Topic.

  2. [RoleType] : Topic.

4.2.18 UniqueOccurrence Constraint

A uniqueoccurrence constraint defines a way to constraint that occurrences of a given type with the same value can only be present on one topic in a given map..

  1. [TopicType] : Topic.

  2. [OccurrenceType] : Topic.

5 TMCL-Rule

TMCL Rule allows to declare set of assertions about topic maps. It is a rule-based language which leverages TMQL constructs for specifying conditions and assertions.

TMCL Rule is close to ISO/IEC 19757-3 (Document Schema Definition Languages (DSDL)- Part 3: Rule-based validation Schematron). Schematron allows do define validation rules for XML documents. TMCL-Rule leverages experience from other rule-based languages and allows specifying constraints based on TMDM.

5.1 RuleItem

A RuleItemdefines a set of assertions about a topic map. The RuleItem consists of an optional selector, and one or more assertions.

A constraint in a form of a if-then rule RuleItem items have the following properties:

  1. [ruleID] : A string.. Is used to identify a rule in a schema

  2. [ruleName] : A string.. Is used to provide a name for a rule

  3. [selector] : A string, optional.. A TMQL expression which generates a list of tuples

  4. [assertItem] : A set of AssertItems. AssertItems specify constraints in a context of a selector and specify error messages

5.2 AssertItem

A constraint in a form of a if-then rule AssertItem items have the following properties:

  1. [parent] : RuleItem. Reference to a parent RuleItem

  2. [constraintID] : A string.. Is used to identify a constraint in a schema

  3. [type] : TopicIdentification,optional.. reference to a category of an assertion, default category is "Error"

  4. [test] : A string, optional.. TMQL expression, can include variable $self for addressing list of tuples produced by selector

  5. [every] : A string, optional. TMQL expression, requires a selector. It is a shortcut for an expression "every $1, $2... in 'tuple list' satisfies P($1,$2,...)"

  6. [some] : A string, optional.. TMQL expression, requires a selector. It is a shortcut for an expression "some $1, $2... in 'tuple list' satisfies P($1,$2,...)"

  7. [message] : A string. Contains a human-oriented explanation of a conflict . It can include TMQL sub-expressions with $self, $1,$2... variables

6 Conflict Items

Conflict Items represent results of a validation process.

Basic Conflict Item has a 'message' property which describes a conflict in a human-readable format. Specific conflicts can record additional information in Conflict Items

6.1 ConflictItem

A Conflict item represents a conflict generated by a constraint.

A construct to represent a result of a constraint validation. ConflictItem items have the following properties:

  1. [category] : TopicIdentification. Reference to a category of a conflict such as 'Error', 'Warning'

  2. [schemaID] : A string.. Reference to Topic Map Schema which contains a constraint which generated a conflict.

  3. [constraintID] : A string.. Reference to a constraint which generates a conflict.

  4. [message] : A string.. Contains a human-oriented explanation of a conflict .

TMCL-Schema constraints generate subtypes of a ConflictItem which correspond to specific constraints:
- SubjectLocatorCardMinConflictItem
- SubjectLocatorCardMaxConflictItem
- SubjectIdentifierCardMinConflictItem
- SubjectIdentifierCardMaxConflictItem
- TopicNameCardMinConflictItem
- TopicNameCardMaxConflictItem
- TopicNameMatchConflictItem
- VariantNameCardMinConflictItem
- VariantNameCardMaxConflictItem
- VariantNameMatchConflictItem
- OccurrenceCardMinConflictItem
- OccurrenceCardMaxConflictItem
- OccurrenceCardMatchConflictItem
- OccurrenceDataTypeConflictItem
- PlayRoleCardMinConflictItem
- PlayRoleCardMaxConflictItem
- OtherRoleCardMinConflictItem
- OtherRoleCardMaxConflictItem
- OtherRoleAllPlayersFromConflictItem
- OtherRoleOneOfConflictItem
- OtherRoleIsUniqueConflictItem
- RoleCardMinConflictItem
- RoleCardMaxConflictItem
- RoleAllPlayersFromConflictItem
- RoleOneOfConflictItem
- RoleIsUniqueConflictItem

7 Topic Map Schema References

TMCL enables topic map authors to specify a schema to which the topic map is conformant. This is achieved by reifying the topic map with a topic and assigning an occurrence to that topic of type TMCLSchemaReference.

The following PSI is used to denote the occurrence type for schema references.

[a: http://www.isotopicmaps.org/tmcl/#TMCLSchemaReference]

This is used to type a occurrence on a topic that reifies the topic map in order to reference the schema for this topic map instance. The value of the occurrence must reference a valid TMCL XML representation or a topic of type Schema.

8 Schema Composition

Schema composition is the ability to take two or more schemas and compose them into a single schema. Given that a schema consists of a set of constraints, schema composition merely takes all the constraints from all schemas being composed and returns a single schema that consists of all constraints. Applications are free to identify and remove redundant constraints and generate conflicts should any constraints be contradictory.

More formally:

Given
  Schema : s1, s2
  Constraint : c1, c2, c3, c4, c5
  s1 := {c1, c2, c3}  
  s2 := {c4, c5}
That
  Compose(s1, s2) => s3
  s3 := {c1, c2, c3, c4, c5}
    

Bibliography

TMCLreq, TMCL Requirements, ISO, 2004

TMCLuc, TMCL Use Cases, ISO, 2004

TMQLreq, TMQL Requirements, ISO, 2003