<!DOCTYPE TEI.2 PUBLIC '-//C. M. Sperberg-McQueen//DTD
          TEI Lite 1.0 plus SWeb (XML)//EN'
          '../../../People/cmsmcq/lib/swebxml.dtd'>
<?xml-stylesheet type="text/xsl" href="../../../People/cmsmcq/lib/swebtohtml.xsl"?> 
<TEI.2 rend="w3c-public">
<teiHeader>
<fileDesc>
<titleStmt>
<title>SML reference constraints</title>
</titleStmt>
<publicationStmt>
</publicationStmt>
<sourceDesc>
<p>Created in electronic form; no source.</p>
</sourceDesc>
</fileDesc>
</teiHeader>
<text>
<front>
<titlePage>
<docTitle>
<titlePart>SML reference constraints</titlePart>
</docTitle>
<docAuthor>C. M. Sperberg-McQueen</docAuthor>
<docDate>3-10 January 2008</docDate>
</titlePage>
</front>

<body>
<p>This document is an attempt to clarify the design story for the
reference constraints defined by <ptr type="bibref" target="SML"/>.
It grows out of discussions of 
issue 5063 against the SML spec
(<xref>http://www.w3.org/Bugs/Public/show_bug.cgi?id=5063</xref>), 
but goes beyond the specific items raised there.</p>
<p>
Section <ptr type="secnum" target="usecases"/>
describes some simple usage scenarios and the kinds of constraint
one might wish to impose on the data in them.
Section <ptr type="secnum" target="how"/>
describes different possible ways of capturing those constraints
in SML.
</p>
<div id="usecases">
<head>Scenarios</head>
<p>This section describes a couple of concrete examples, at a very high
level.  [More concrete examples might be useful here.]</p>

<div>
<head>Courses</head>
<p>The SML spec describes an example application which keeps
track of students and courses at a university.  (Different
examples in different parts of the spec describe slightly different
concrete syntax, but see Appendix C for the fullest account.)
</p>
<p>For each student, the system tracks the courses
the student is enrolled in for the current term.
The courses enrolled in are named by reference:  in the
examples of Appendix C, the
<ident>u:EnrolledCourse</ident> element refers to a
<ident>u:Course</ident> element in another XML document.
We would like to be able to specify<list>
<item>that every course-reference from the student's
record refers to an actual course</item>
</list>
</p>
<p>For each approved course, the system documents the course code 
(department and course number), title, and prerequisite
courses.  The prerequisite courses are named by reference.
We would like to be able to specify<list>
<item>that every reference to a prerequisite from any course
record refers to an actual course</item>
<item>that no course is directly or indirectly a prerequisite for
itself (if this occurs, it's an almost certain indication of
corrupt data)</item>
</list></p>
<p>How are these constraints to be expressed?  In principle, it
appears to depend on how, in particular vocabulary, we recognize
student records, course records, and the particular kind of reference
involved in a constraint:
<list>
<item><p>If we recognize a course record by means of the element's
expanded name, then the constraint on student records can take the
form <q type="block">The target of this reference must be an element with the
expanded name <q><code>{http://www.university.example.org/ns}
Course</code></q>.</q></p>
<p>This is what <ident>sml:targetElement</ident> does.</p></item>

<item><p>If we recognize a course record by means of the element's
type, then the constraint on student records can take the
form <q type="block">The target of this reference must be an element with the
governing type <q><code>{http://www.university.example.org/ns}
CourseType</code></q>.</q></p>
<p>This is what <ident>sml:targetType</ident> does.</p></item>

<item><p>However we recognize a course-prerequisite reference
(as distinct from any other references which have a course as their
target or a course as their source), we need so say 
<q type="block">The references of this set of reference must not
form a cycle.</q></p>
<p>This is what <ident>sml:acyclic</ident> does.</p></item>

</list>
</p>
<p>Where do the constraints get imposed?
<list>
<item>If we recognize a student record's reference to a
course, or a course's reference to a prerequisite course,
by means of its expanded name (or more precisely by means
of its being bound to a particular governing element declaration), 
then we want <emph>either</emph> to put the
<ident>sml:targetElement</ident> or <ident>sml:targetType</ident> 
constraint on that element declaration (e.g. on
<q><code>{http://www.university.example.org/ns}
EnrolledCourse</code></q> or 
<q><code>{http://www.university.example.org/ns}
Prereq</code></q>), <emph>or</emph> to put the
constraint on a type which is used only for the one
particular element.
</item>
<item>If we recognize the particular references
by means of their governing type definitions, then we want to put the
<ident>sml:targetElement</ident> or <ident>sml:targetType</ident> 
constraint on that type definition (e.g. on
<q><code>{http://www.university.example.org/ns}
EnrolledCourseType</code></q> or
<q><code>{http://www.university.example.org/ns}
PrereqRefType</code></q>).
</item>
</list>
</p>
</div>
<div>
<head>Refinements and restrictions on courses</head>
<p>What happens when we wish to refine the schema?</p>
<p>If we introduce a distinction between graduate courses
and undergraduate (upper and lower division) students 
and courses, we don't want to wish
to lose the constraints.</p>
<p>We may also wish to refine the constraints.  For example,
we might wish to specify that:
<list>
<item>No undergraduate course
may have any graduate course among its prerequisites.</item>
<item>No lower-division undergraduates
may have any graduate courses among their enrolled courses.</item>
</list>
</p>
<p>Two aspects need to be considered: the target and the source
of the reference.<list>
<item>If the target is identified by type, any refinement of
the target will continue to satisfy the constraint.</item>
<item>If the target is identified by element declaration, 
do other elements in that element's substitution group 
satisfy the constraint?</item>
<item>If the source is identified by type, any refinement of
the source or its containing type will continue to impose 
the constraint.</item>
<item>If the source is identified by element declaration, 
then we need to ensure that refinements of the containing
type satisfy the constraint.</item>
</list>
</p>
</div>
<div>
<head>Hosting dependencies</head>
<p>Imagine an SML model for an IT center, in which there are
documents describing ...</p>
<p>[Description, examples]</p>
<p>We would like to enforce the following constraints:<list>
<item>The <ident>depends-on</ident> relation must not contain
cycles.</item>
<item>[more ...]</item>
</list>
</p>
</div>
</div>
<div id="how">
<head>Possible constraint mechanisms</head>
<p>This section describes some of the design issues relating to
reference constraints, and some of the possible solutions.</p>
<p>...</p>
</div>
</body>
<back>
<div>
<head>References</head>
<listBibl>
<bibl id="SML" n="SML 1.1">
<title>Service Modeling Language, Version 1.1</title>
ed. James Lynn,
Bhalchandra Pandit, 
Valentina Popescu, 
and
Virginia Smith.
Current editor's draft at 
<xref>http://dev.w3.org/cvsweb/~checkout~/2007/xml/sml/build/sml.html?content-type=text/html;%20charset=utf-8</xref>
</bibl>
</listBibl>
</div>
</back>
</text>
</TEI.2>
<!-- Keep this comment at the end of the file
Local variables:
mode: xml
sgml-default-dtd-file:"/Library/SGML/Public/Emacs/sweb.ced"
sgml-omittag:t
sgml-shorttag:t
End:
-->

