<?xml version="1.0" encoding="utf-8"?><!--
/*
 * Copyright © 2008 World Wide Web Consortium,
 *
 * (Massachusetts Institute of Technology, European Research Consortium for
 * Informatics and Mathematics, Keio University). All Rights Reserved. This
 * work is distributed under the W3C® Document License [1] in the hope that
 * it will be useful, but WITHOUT ANY WARRANTY; without even the implied
 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 *
 * [1] http://www.w3.org/Consortium/Legal/2002/copyright-documents-20021231
 */
    --><spec xmlns:xlink="http://www.w3.org/1999/xlink" w3c-doctype="cr">
    <header>
        <title>Service Modeling Language, Version 1.1</title>

        <w3c-designation>http://www.w3.org/TR/2008/CR-sml-20081125/</w3c-designation>
        <w3c-doctype>W3C Candidate Recommendation</w3c-doctype>

        <pubdate>
            <day>25</day>
            <month>November</month>
            <year>2008</year>
        </pubdate>
        <publoc>
            <loc href="http://www.w3.org/TR/2008/CR-sml-20081125/" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">http://www.w3.org/TR/2008/CR-sml-20081125/</loc>
        </publoc>
    <altlocs>
      <loc role="xml" href="sml.xml" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">XML</loc>
    </altlocs>
    <prevlocs>
            <loc href="http://www.w3.org/TR/2008/WD-sml-20080912/" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">http://www.w3.org/TR/2008/WD-sml-20080912/</loc>
    </prevlocs>
        <latestloc>
            <loc href="http://www.w3.org/TR/sml/" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">http://www.w3.org/TR/sml/</loc>
        </latestloc>
    <authlist>
      <author role="editor">
        <name>Bhalchandra Pandit</name>
        <affiliation>Microsoft Corporation</affiliation>
      </author>
      <author role="editor">
        <name>Valentina Popescu</name>
        <affiliation>IBM Corporation</affiliation>
      </author>
      <author role="editor">
        <name>Virginia Smith</name>
        <affiliation>HP</affiliation>
      </author>
    </authlist>
    <abstract>
      <p>This specification defines the Service Modeling Language, Version 1.1 (SML) used to
      model complex services and systems, including their
      structure, constraints, policies, and best practices. SML uses
      XML Schema and Schematron. </p>
    </abstract>
    <status id="status">
      
      <p>

                <emph>This section describes the status of this document at the
      time of its publication. Other documents may supersede this
      document. A list of current W3C publications and the latest revision
      of this technical report can be found in the <loc href="http://www.w3.org/TR/" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">W3C technical reports index</loc> at
      http://www.w3.org/TR/.</emph>
</p>

      <p>
          W3C publishes a <loc href="http://www.w3.org/2005/10/Process-20051014/tr.html#maturity-levels" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">Candidate Recommendation</loc> to indicate that the document is believed to be stable
          and to encourage implementation by the developer community.
          The <loc href="http://www.w3.org/XML/SML/" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">Service Modeling Language
          (SML) Working Group</loc>
          expects to request that the Director advance this document to
          <loc href="http://www.w3.org/2005/10/Process-20051014/tr.html#maturity-levels" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">Proposed Recommendation</loc> 
          once the Working Group has demonstrated
          two implementations of each required feature and at least one implementation of
          each optional feature affecting interoperability.
          The SML Working Group, working closely with the developer community, expects to show
          implementations by December 2008. This estimate is based on known
          implementations. The Working Group does not plan to
          request to advance to Proposed Recommendation prior to 01 January 2009.
      </p>
      <p>
          No features have been identified as "features at risk" by the SML Working Group.
      </p>
      <p>
            The major substantive change since the previous publication of this 
  specification as a Last Call Working Draft has been the introduction
  of what are expected to be the final namespace names for the SML and 
  SML-IF namespaces; previously each new Working Draft used a new pair
  of namespace names.  Other editorial and cosmetic changes have also
  been made.
      </p>
      <p>
          This document has been developed by the <loc href="http://www.w3.org/XML/SML/" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">Service Modeling Language
          (SML) Working Group</loc>, which is a part of the <loc href="http://www.w3.org/XML/" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">Extensible Markup Language (XML) Activity</loc>.
      </p>

      <p>Publication as a Candidate Recommendation does not imply endorsement by
      the W3C Membership. This is a draft document and may be updated,
      replaced or obsoleted by other documents at any time. It is
      inappropriate to cite this document as other than work in
      progress.</p>

      <p>Please submit comments on this document using the
      <loc href="http://www.w3.org/XML/SML/#issues" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">procedure described on the Working Group’s home page</loc>.
      In summary, the Working Group solicits comments in Bugzilla from those who have access,
      and on the Working Group’s
      <loc href="mailto:public-sml@w3.org" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">public mailing list</loc>
      (<loc href="http://lists.w3.org/Archives/Public/public-sml/" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">public archive</loc>)
      from others.</p>

      <p>This document was produced by a group operating under the
      <loc href="http://www.w3.org/2004/01/pp-impl/41079/status" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">5 February 2004 W3C Patent Policy</loc>.
      W3C maintains a public list of
      any patent disclosures made in connection with the deliverables
      of the group; that page also includes instructions for
      disclosing a patent. An individual who has actual knowledge of a
      patent which the individual believes contains Essential Claim(s)
      must disclose the information in accordance with
      <loc href="http://www.w3.org/Consortium/Patent-Policy-20040205/#sec-Disclosure" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">
      section 6 of the W3C Patent Policy</loc>.</p>
    </status>

    <langusage>
        <language id="en-US">English</language>
    </langusage>
    <revisiondesc>
        <p>Last Modified: $Date: 2008/11/25 19:09:09 $</p>
    </revisiondesc>
    </header>
    <body>
      <div1 id="Introduction">
    <head>Introduction (Non-Normative)</head>

<p>The Service Modeling Language (SML) provides a rich set of
constructs for creating models of complex services and systems. Depending on the application domain, these
models may include information such as configuration, deployment,
monitoring, policy, health, capacity planning, target operating range,
service level agreements, and so on. Models provide value in several
important ways.</p>
<olist>
  <item>
<p>Models focus on capturing all
    <b>invariant aspects</b> of a service/system that must be
    maintained for the service/system to function properly.</p>
  </item>
  <item>
<p>Models represent a powerful mechanism for
    <b>validating changes</b> <b>before</b> applying the changes
    to a service/system. Also, when changes happen in a running
    service/system, they can be validated against the intended state
    described in the model. The actual service/system and its model together
    enable a <b>self-healing service/system</b> ― the ultimate objective.
    <b>Models of a service/system must necessarily stay decoupled from the
    live service/system to create the control loop</b>.</p>
  </item>
  <item>
<p>Models are units of
    <b>communication</b> <b>and collaboration</b> between
    designers, implementers, operators, and users; and can easily be shared,
    tracked, and revision controlled. This is important because complex
    services are often built and maintained by a variety of people playing
    different roles.</p>
  </item>
  <item>
<p>Models drive <b>modularity</b>,
    <b>re-use, and standardization</b>. Most real-world complex
    services and systems are composed of sufficiently complex parts.  Re-use
    and standardization of services/systems and their parts is a key factor
    in reducing overall production and operation cost and in increasing
    reliability.</p>
  </item>
  <item>
<p>Models enable
    increased <b>automation</b> of
    management tasks. Automation facilities exposed by the majority of
    services/systems today could be driven by software ― not people ―
    both for reliable initial realization of a service/system as well as for
    ongoing lifecycle management.</p>
  </item>
</olist>


<p>A model in SML is realized as a set of interrelated XML documents. The XML
documents contain information about the parts of a service, as well as
the constraints that each part must satisfy for the service to function
properly. Constraints are captured in two ways:</p>
<olist>
  <item>
                    <p>

                        <b>Schemas</b> ― these are
    constraints on the structure and content of the documents in a model. SML
    uses XML Schema [<bibref ref="XSD1"/>, <bibref ref="XSD2"/>] as the schema language. 
    In addition SML defines a set of extensions to XML Schema to support 
    references that may cross document boundaries.</p>
  </item>
  <item>
                    <p>

                        <b>Rules</b> ― are Boolean expressions that constrain
  the structure and content of documents in a model. SML uses 
  Schematron [<bibref ref="Schematron"/>, <bibref ref="intro_schematron"/>, <bibref ref="improving_schematron"/>] and
  XPath [<bibref ref="XPath"/>] for rules.</p>
  </item>
</olist>

<p>One of the important operations on the model is
to establish its validity. This involves checking whether all data in a model
satisfies the schemas and rules declared. </p>

<p>This specification focuses primarily on defining the extensions to XML Schema 
for references that cross document boundaries, Schematron usage in SML, 
as well as the process of model validation. It is
assumed that the reader is familiar with XML Schema and Schematron. </p>


<p>SML scenarios require several features that either do not exist or are not
fully supported in XML Schema. These features can be classified as
follows:</p>
<olist>
  <item>
                    <p>

<b>SML references</b> – XML documents introduce boundaries 
  across content that needs to be treated as a unit. XML Schema does not have any support
    for references that cross documents, although it does support references to elements in the same document through 
    <code>xs:ID</code>, <code>xs:IDREF</code>, <code>xs:key</code> and <code>xs:keyref</code>.
    References between elements defined in separate SML <termref def="model">model</termref> documents
    are fundamental to the SML specification. SML extends XML Schema to support references
    that may cross document boundaries, and a set of constraints
    on those references that apply regardless of whether they cross document
    boundaries or not.</p>
  </item>
  <item>
                    <p>

<b>Rules</b> – XML Schema does not support a language
    for defining arbitrary constraints on the structure and content of XML
    documents. SML uses Schematron to express assertions on the structure and
    content of XML documents.</p>
  </item>
</olist>

<p>XML Schema supports two forms of extension: "attributes in different
namespace" and "application information elements"; both forms are used
by SML extensions.</p>
</div1>
<div1 id="Notations_and_Terminology">
<head>Notations and Terminology</head>
<div2 id="Notational_Conventions">
  <head>Notational Conventions</head>

  <p>
      The keywords "<rfc2119>MUST</rfc2119>", "<rfc2119>MUST
      NOT</rfc2119>", "<rfc2119>REQUIRED</rfc2119>",
      "<rfc2119>SHALL</rfc2119>", "<rfc2119>SHALL
      NOT</rfc2119>", "<rfc2119>SHOULD</rfc2119>",
      "<rfc2119>SHOULD NOT</rfc2119>",
      "<rfc2119>RECOMMENDED</rfc2119>",
      "<rfc2119>MAY</rfc2119>", and
      "<rfc2119>OPTIONAL</rfc2119>" in this document are to be
      interpreted as described in RFC 2119 [<bibref ref="RFC2119"/>].
  </p>

  <p>This specification uses the Augmented Backus-Naur Form (ABNF)
  notation [<bibref ref="RFC2234"/>].
  </p>

  <p>This specification follows the same conventions for schema components as those used in the
  XML schema specification [<bibref ref="XSD1"/>]. That is, 
  references to properties of schema components, such as {example property}, are links to the 
  relevant definition, set off with curly braces.
  References to properties of information items as defined in [<bibref ref="XMLInfoset"/>], 
  such as [children], 
  are notated as links to the relevant section thereof, set off with square brackets.  
  </p>

  <p>This specification refers to terms such as XML document, element, attribute,
  etc. for the sake of brevity. The alternative would be to use terms like "XML
  document or a <xspecref href="http://www.w3.org/TR/xml-infoset/#intro.synthetic" xlink:type="simple" xlink:show="new" xlink:actuate="onRequest">
  Synthetic Infoset</xspecref>",
  "<xspecref href="http://www.w3.org/TR/xml-infoset/#infoitem.element" xlink:type="simple" xlink:show="new" xlink:actuate="onRequest">element information item</xspecref>",
  "<xspecref href="http://www.w3.org/TR/xml-infoset/#infoitem.attribute" xlink:type="simple" xlink:show="new" xlink:actuate="onRequest">attribute information item</xspecref>", etc. at each place.  This
  would make the specification excessively verbose without adding to or changing
  the meaning of the existing text. The use of the concise terms is not intended
  to exclude other XML representations. The concepts defined in this
  specification apply to all forms of XML representations.
  </p>

<p>The content of this specification is normative except for sections 
or texts that are explicitly marked as non-normative. If a section is 
marked as non-normative, then all contained sub-sections are non-normative, 
even if they are not explicitly marked as such. All notes are non-normative unless
otherwise specified.
</p>
    
</div2>
<div2 id="Terminology">
<head>Terminology</head>
<p>The following terms are used in this specification. They are listed here in alphabetical order.
</p>
  <glist>
    
    <gitem>
      <label id="document">Document</label>
      <def>
    <p>A well-formed XML <term>document</term>, as defined in [<bibref ref="XML10"/>].</p>
      </def>
    </gitem>
    <gitem>
      <label id="implementation_defined">Implementation-Defined</label>
      <def>
    <p>An <term>implementation-defined</term> feature or behavior may vary among
    <termref def="model">model processors</termref>; the precise behavior is not specified
    by this specification but <rfc2119>MUST</rfc2119> be specified by the implementor 
    of each <termref def="model">model processor</termref>. 
    </p>
      </def>
    </gitem>
    <gitem>
      <label id="implementation_dependent">Implementation-Dependent</label>
      <def>
    <p>An <term>implementation-dependent</term> feature or behavior may vary among
    <termref def="model">model processors</termref>; the precise behavior is not specified
    by this or any other W3C specification and is not required to be specified 
    by the implementor for any particular implementation. 
    </p>
      </def>
    </gitem>
  <gitem>
    <label id="model">Model</label>
    <def>
      <p>A set of inter-related <termref def="document">documents</termref> that describe a service
      or system.  Each <term>model</term> consists of two disjoint subsets of
      documents – <termref def="model_definition">model definition documents</termref> and 
      <termref def="model_instance">model instance documents</termref>.</p>
    </def>
  </gitem>
  <gitem>
    <label id="model_definition">Model Definition Documents</label>
    <def>
      <p>The subset of documents in a <termref def="model">model</termref> that describes the schemas
      and rules that govern the structure and content of the model's
      documents.  This specification defines two types of <term>model
      definition</term> document, <termref def="schemaDocument">schema documents</termref> and 
      <termref def="ruleDocument">rule documents</termref>,
      but permits implementations to
      define other types of model definition documents. Such other
      types of model definition documents do not play any role in 
      <termref def="model_validation_t">model validation</termref>.</p>
    </def>
  </gitem>
  <gitem>
    <label id="model_instance">Model Instance Documents</label>
    <def>
      <p>The subset of documents in a <termref def="model">model</termref> that describes the structure
      and content of the modeled entities.</p>    
    </def>
  </gitem>
  <gitem>
    <label id="model_processor">Model Processor</label>
    <def>
      <p>A <term>model processor</term> is an embodiment that processes a conforming SML model
      using, in whole or in part, semantics defined by this specification.</p>
    </def>
  </gitem>
  <gitem>
    <label id="model_validation_t">Model Validation</label>
    <def>
      <p>

                                <term>Model validation</term> is the process of 
      determining whether or not a <termref def="model">model</termref> 
      is both conforming and valid. [<specref ref="Conformance"/>] </p>
    </def>
  </gitem>
  <gitem>
    <label id="model_validator">Model Validator</label>
    <def>
      <p>A <term>model validator</term> is a <termref def="model">model processor</termref> capable of
      performing <termref def="model_validation_t">model validation.</termref>
</p>
    </def>
  </gitem>
  <gitem>
    <label id="rule">Rule</label>
    <def>
      <p>A <term>rule</term> is a boolean expression that constrains the structure and content of a
      set of documents in a <termref def="model">model</termref>. </p>
    </def>
  </gitem>
  <gitem>
    <label id="ruleBinding">Rule Bindings</label>
    <def>
        <p>A <term>rule binding</term> is an association of a set of one or more
        <termref def="ruleDocument">rule documents</termref> with a set of zero or more model documents. The
        documents associated with a given rule document are said to be "bound"
        to it. For a model to be valid, every <termref def="model_definition">definition document</termref>
         and <termref def="model_instance">instance document</termref>
        in the <termref def="model">model</termref> must conform to the constraints defined by every rule document it is bound
        to. It is permissible for a rule document to have no bindings
        associated with it, and for a model document to be bound to zero rule
        documents.</p>
    </def>
  </gitem>    
  <gitem>
    <label id="ruleDocument">Rule Document</label>
    <def>
      <p>A <term>rule document</term> is a <termref def="model_definition">model definition document</termref> 
      consisting of <termref def="schematron_constraint">Schematron constraints</termref>.</p>
    </def>
  </gitem>
      <gitem>
    <label id="schemaDocument">Schema document</label>
    <def>
      <p>A <term>schema document</term> is a <termref def="model_definition">model definition document</termref> 
      that conforms to the XML Schema specification [<xspecref href="#XSD1" xlink:type="simple" xlink:show="new" xlink:actuate="onRequest">XML Schema Structures</xspecref>]
      definition of a schema document.</p>
    </def>
  </gitem>  
  <gitem>
    <label id="schematron_constraint">Schematron Constraint</label>
    <def>
      <p>The information contained within a single <code>sch:schema</code> element.
      </p>
    </def>
  </gitem>    
  <gitem>
    <label id="reference">SML Reference</label>
    <def>
      <p>An <term>SML Reference</term> is an element with an sml:ref attribute
      whose value is "true".</p>
      <note>
                                <p>Conceptually, an SML reference is used to signal a link from
       one element in an SML model to another element in the same model.</p>
</note>
    </def>
  </gitem>    
  <gitem>
    <label id="reference_scheme">SML Reference Scheme</label>
    <def>
      <p>An <term>SML Reference Scheme</term> is a set of rules defining the syntax used to
        create an instance of the reference scheme in the context of 
        an <termref def="reference">SML reference</termref>, plus a set of
        rules for resolving an instance of the reference scheme
         to its <termref def="target">target</termref>.  Whenever "reference
        scheme" occurs in this specification, it should be assumed to mean "SML
        reference scheme" unless otherwise noted.  Despite similar names, the term SML
        reference scheme is unrelated to XPointer schemes and URI schemes.
      </p>    
    </def>
  </gitem>    
  <gitem>
    <label id="target">Target</label>
    <def>
      <p>An element in a model to which an <termref def="reference">SML reference</termref> 
      resolves is called the <term>target</term> of that 
      SML reference.</p>    
    </def>
  </gitem>    
  <gitem>
    <label id="target_complete_identifier">Target-complete Identifier</label>
    <def>
      <p>A <term>target-complete identifier</term> is a URI or IRI that contains all the 
      information required to locate the <termref def="target">target</termref> of an <termref def="reference">SML reference</termref>. 
      It is a consequence 
      of this definition that a target-complete identifier cannot be a relative URI/IRI.</p>
    </def>
  </gitem>
  </glist>

</div2>
<div2 id="XML_Namespaces">
<head>XML Namespaces</head>

<p>
<specref ref="Table1"/> lists XML namespaces that are used in this
specification. The choice of any namespace prefix is arbitrary and not
semantically significant.</p>

<table border="1" cellspacing="0" cellpadding="5" id="Table1">
  <caption>XML Namespaces used in this specification.</caption>
  <thead>
    <tr>
      <th rowspan="1" colspan="1">Prefix</th>
      <th rowspan="1" colspan="1">XML Namespace</th>
      <th rowspan="1" colspan="1">Specification(s)</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td rowspan="1" colspan="1">
                                <code>sml</code>
</td>
      <td rowspan="1" colspan="1">
                                <code>http://www.w3.org/ns/sml</code>
</td>
      <td rowspan="1" colspan="1">This specification</td>
    </tr>
    <tr>
      <td rowspan="1" colspan="1">
                                <code>smlfn</code>
</td>
      <td rowspan="1" colspan="1">
                                <code>http://www.w3.org/ns/sml-function</code>
</td>
      <td rowspan="1" colspan="1">This specification</td>
    </tr>
    <tr>
      <td rowspan="1" colspan="1">
                                <code>xs</code>
</td>
      <td rowspan="1" colspan="1">
                                <code>http://www.w3.org/2001/XMLSchema</code>
</td>
      <td rowspan="1" colspan="1">[<bibref ref="XSD1"/>, <bibref ref="XSD2"/>]</td>
    </tr>
    <tr>
      <td rowspan="1" colspan="1">
                                <code>sch</code>
</td>
      <td rowspan="1" colspan="1">
                                <code>http://purl.oclc.org/dsdl/schematron</code>
</td>
      <td rowspan="1" colspan="1">[<bibref ref="Schematron"/>]</td>
    </tr>
  </tbody>
</table>
</div2>
</div1>
<div1 id="Dependencies">
<head>Dependencies on Other Specifications</head>

<p>Other specifications on which this one depends are listed in [<bibref ref="Normative-References"/>].
</p>
</div1>
<div1 id="References">
<head>SML References</head>

<p>Support for <termref def="reference">SML references</termref> in an SML <termref def="model">model</termref> includes:</p>
<olist>
  <item>
<p>The ability to use multiple SML reference schemes for an SML reference. </p>
  </item>
  <item>
<p>An extensibility mechanism allowing new SML reference schemes to be defined.
  </p>
  </item>
  <item>
<p>Constraints on the type of a referenced element. </p>
  </item>
  <item>
<p>The ability to define key, unique, and key reference constraints
  across SML references.</p>
  </item>
</olist>

<p>
                <termref def="model_validator">Model validators</termref> 
<rfc2119>MUST</rfc2119> support <termref def="reference">SML references</termref> 
as defined by this specification.
</p>

<p>Appendix <specref ref="SML_References_Sample"/> has an  example that
shows how SML references are defined and used.
</p>

<div2 id="Reference_Definitions">
<head>SML Reference Definitions</head>

<div3 id="SML_Reference">
<head>SML Reference</head>
<p>
An element information item in an SML model instance document 
is as an <termref def="reference">SML reference</termref>
 if and only if it has an attribute information item for which all of the following is true:
</p>
<olist>
<item>
                            <p>
Its <xspecref href="http://www.w3.org/TR/xml-infoset/#infoitem.attribute" xlink:type="simple" xlink:show="new" xlink:actuate="onRequest">[local name]</xspecref>
is <code>ref</code>
                            </p>
</item>
<item>
                            <p>Its <xspecref href="http://www.w3.org/TR/xml-infoset/#infoitem.attribute" xlink:type="simple" xlink:show="new" xlink:actuate="onRequest">[namespace name]</xspecref>
is <code>http://www.w3.org/ns/sml</code>
                            </p>
</item>
<item>
                            <p>Its <xspecref href="http://www.w3.org/TR/xml-infoset/#infoitem.attribute" xlink:type="simple" xlink:show="new" xlink:actuate="onRequest">[normalized value]</xspecref>, after whitespace normalization 
using <code>collapse</code> following <xspecref href="http://www.w3.org/TR/xmlschema-2/" xlink:type="simple" xlink:show="new" xlink:actuate="onRequest">schema rules</xspecref>, is either <code>"true"</code> or <code>"1"</code>.</p>
</item>
</olist>

<note>

<p>This mechanism enables schema-less identification of SML references; i.e.,
SML references can be identified without relying on the Post Schema Validation
Infoset (PSVI). [<bibref ref="XSD1"/>]</p>
</note>

<p>It is implementation-defined whether <termref def="model_processor">model processors</termref> 
that are not also <termref def="model_validator">model validators</termref>
 use the XML Infoset [<bibref ref="XMLInfoset"/>] or the Post Schema
Validation Infoset (PSVI) [<bibref ref="XSD1"/>] for SML reference
identification.
</p>

<note>

<p>SML model validators must use PSVI to identify SML references. See
<specref ref="Conformance"/>.</p>
</note>

<p>An SML reference is considered to be an instance of a 
specific SML <termref def="reference_scheme"> reference
scheme</termref> if it can be identified as such according to that SML reference scheme's
rules. See <specref ref="Reference_Schemes"/>. An SML reference MAY be an instance of multiple SML
reference schemes.</p>
<p>Although its normative definition allows several syntaxes to be used to
identify an SML reference, for the sake of brevity and consistency, 
the rest of this specification uses 
<code>sml:ref="true"</code> to denote an SML reference in examples and text.</p>

<p>The following example shows an SML reference that is an instance of the SML URI Reference scheme.</p>
<eg xml:space="preserve">
&lt;RefElement sml:ref="true"&gt;
    &lt;sml:uri&gt;targetDocument.xml&lt;/sml:uri&gt;
&lt;/RefElement&gt;
</eg>

</div3>

<div3 id="Null_Reference">
<head>Null SML Reference</head>
<p>
An SML reference is null if and only if it has an attribute information 
item for which all of the following is true</p>
<olist>
    <item>
                            <p>Its <xspecref href="http://www.w3.org/TR/xml-infoset/#infoitem.attribute" xlink:type="simple" xlink:show="new" xlink:actuate="onRequest">[local name]</xspecref>
is <code>nilref</code>
                            </p>
</item>
<item>
                            <p>Its <xspecref href="http://www.w3.org/TR/xml-infoset/#infoitem.attribute" xlink:type="simple" xlink:show="new" xlink:actuate="onRequest">[namespace name]</xspecref>
is <code>http://www.w3.org/ns/sml</code>
                            </p>
</item>
<item>
                            <p>Its <xspecref href="http://www.w3.org/TR/xml-infoset/#infoitem.attribute" xlink:type="simple" xlink:show="new" xlink:actuate="onRequest">[normalized value]</xspecref>
after whitespace normalization 
using <code>collapse</code> following <xspecref href="http://www.w3.org/TR/xmlschema-2/" xlink:type="simple" xlink:show="new" xlink:actuate="onRequest">schema rules</xspecref>, is either <code>"true"</code> or <code>"1"</code>.</p>

</item>

</olist>
<p>It is a consequence of the preceding that this specification assigns no meaning
to the  <code>sml:nilref</code> attribute when it is used on an element that is not an SML
reference.  Model validators <rfc2119>MAY</rfc2119> choose to warn their invokers should they
detect this condition in a document. 
</p>
<p>The following example shows a null SML reference.</p>
<eg xml:space="preserve">
&lt;RefElement sml:ref="true" sml:nilref="true"&gt;
    &lt;sml:uri&gt;targetDocument.xml&lt;/sml:uri&gt;
&lt;/RefElement&gt;
</eg>
<note>
                        <p>
                            <code>sml:nilref</code> may be useful in the case where the schema author defines a complex
type specifying <code>sml:ref="true"</code> with a fixed value of "true", but the instance author
wants to signal the absence of a target.  
</p>
</note>
<p>It is implementation-defined whether <termref def="model_processor">model processors</termref> 
that are not also <termref def="model_validator">model validators</termref>
 use the XML Infoset [<bibref ref="XMLInfoset"/>] or the Post Schema
Validation Infoset (PSVI) [<bibref ref="XSD1"/>] to identify null SML references.
</p>

<note>

<p>SML model validators must use PSVI to identify null SML references. See
<specref ref="Conformance"/>.</p>
</note>
</div3>

<div3 id="Unresolved_Reference">
<head>Unresolved SML Reference</head>
<p>
An SML reference is 
 unresolved if and only if all of the following is true:
</p>
<olist>
<item>
                            <p>It is a non-null SML reference.</p>
</item>
<item>
<p>None of the <termref def="reference_scheme">reference schemes</termref>,
 which the SML reference is recognized as using,
resolves to an element in the model.</p>
</item> 
</olist>
<note>

                        <p>The notion of unresolved reference is context dependent. 
That is, different <termref def="model_processor">model processors</termref>, 
based on the set of SML reference schemes they understand and which are used in the model 
they process, may consider different SML references to be unresolved. 
</p>

</note>
<p>The following example shows an unresolved SML reference (assuming that the document
<code>dummy.xml</code> does not exist in the model).</p>
<eg xml:space="preserve">
&lt;RefElement sml:ref="true"&gt;
    &lt;sml:uri&gt;dummy.xml&lt;/sml:uri&gt;
&lt;/RefElement&gt;
</eg>
</div3>

<div3 id="SML_Reference_Target">
    <head>SML Reference Target</head>
    <p>The element node that a non-null SML reference resolves to is its target. The target of 
    an SML reference <rfc2119>MUST</rfc2119> be part of the same SML model as the SML reference. 
    Null SML references have no target.</p>
<p>The method of determining which documents are part of an SML model is
implementation-defined. </p>
<note>
                        <p>For example, an SML model may consist of documents listed in a configuration file
 or an SML model could be construed as the transitive closure of documents 
 referred to by any SML references starting from a set of documents known 
 to be in the model. 
</p>

</note>
<p>The following example shows an SML reference that targets the second <code>Course</code>
child element of the root element of the document <code>target.xml</code>.</p>
<eg xml:space="preserve">
&lt;RefElement sml:ref="true" xmlns:e="urn:example"&gt;
    &lt;sml:uri&gt;target.xml#smlxpath1(e:Course[2])&lt;/sml:uri&gt;
&lt;/RefElement&gt;

document 'target.xml':
----------------------
&lt;Courses xmlns="urn:example"&gt;
    &lt;Course&gt;
        &lt;Name&gt;PHY101&lt;/Name&gt;
        &lt;Grade&gt;A&lt;/Grade&gt;
    &lt;/Course&gt;
    &lt;Course&gt;
        &lt;Name&gt;MAT101&lt;/Name&gt;
        &lt;Grade&gt;A&lt;/Grade&gt;
    &lt;/Course&gt;
&lt;/Courses&gt;
</eg>
</div3>

</div2>

<div2 id="Reference_Semantics">
<head>SML Reference Semantics</head>

<p>
<termref def="model_validator">Model validators</termref> <rfc2119>MUST</rfc2119> 
attempt to resolve
an SML reference using all the reference schemes of which the SML reference
is recognized as an instance.
</p>

<div3 id="At_Most_One_Target">
<head>At Most One Target</head>

<p>Every non-null SML reference <rfc2119>MUST</rfc2119> target
at most one element in a <termref def="model">model</termref>. This means that each 
recognized reference scheme used in the SML reference
 <rfc2119>MUST NOT</rfc2119> resolve to more than one target.</p>
<p>The following example shows an SML reference that violates the at-most-one-target rule.</p>
<eg xml:space="preserve">
&lt;RefElement sml:ref="true" xmlns:e="urn:example"&gt;
    &lt;sml:uri&gt;target.xml#smlxpath1(e:Course)&lt;/sml:uri&gt;
&lt;/RefElement&gt;

document 'target.xml':
----------------------
&lt;Courses xmlns="urn:example"&gt;
    &lt;Course&gt;
        &lt;Name&gt;PHY101&lt;/Name&gt;
        &lt;Grade&gt;A&lt;/Grade&gt;
    &lt;/Course&gt;
    &lt;Course&gt;
        &lt;Name&gt;MAT101&lt;/Name&gt;
        &lt;Grade&gt;A&lt;/Grade&gt;
    &lt;/Course&gt;
&lt;/Courses&gt;
</eg>

</div3>
<div3 id="Consistent_References">
<head>Consistent References</head>

<p>If a non-null SML reference is an instance of multiple
reference schemes, 
all recognized reference schemes <rfc2119>MUST</rfc2119> resolve 
to the same target or they all <rfc2119>MUST</rfc2119> be unresolved. 
</p>

</div3>
<div3 id="Identical_Targets">
<head>Identical Targets</head>

<p>To determine if two targets are the same or different, 
<termref def="model_validator">model validators</termref>
 MUST obey 
the following rules.</p>
<olist>
<item>
<p>
If both of the following are true, then a model validator 
<rfc2119>MUST</rfc2119> consider both targets to be the same.</p>
<olist>
<item>

                                    <p>
The definition of the reference scheme(s) specifies how URIs are
transformed to <termref def="target_complete_identifier">target-complete identifiers</termref>.
</p>
</item>
<item>
                                    <p>The two target-complete identifiers are identical using a case-sensitive, 
codepoint-by-codepoint comparison.</p>
</item>
</olist>
</item>
<item>
                            <p>
Otherwise, a model validator <rfc2119>MUST</rfc2119> consider both targets to be different when there is 
something available in the element information items for the targets that tells them apart. For example, if there is an infoset property for which the 2 targets have different values, they are different. This applies recursively for complex-valued properties.
</p>
</item>
<item>
                            <p>
For all other cases, it is implementation-defined whether to treat the targets 
as the same or not.
</p>
</item>
</olist>
</div3>
<div3 id="Multiple_References">
<head>Multiple References  </head>

<p>An element in a document <rfc2119>MAY</rfc2119> be targeted by multiple SML references. 
</p>

</div3>
<div3 id="Null_References">
<head>Null SML References</head>

<p>  
A null SML reference is an explicit declaration of intent by the document author that 
the <termref def="target">target</termref> of the SML reference does not exist. 
If an SML reference is recognized as null, then <termref def="model">model processors</termref>
<rfc2119>MUST NOT</rfc2119> attempt to recognize any reference schemes
used in it.

 </p>

</div3>
<div3 id="Deterministic_References">
<head>Deterministic Evaluation of SML Constraints</head>
<p>
Each non-null SML reference <rfc2119>MUST</rfc2119> satisfy all of the following conditions in
order to be able to deterministically evaluate SML constraints and rules
associated with it.</p>
<olist>
<item>

                            <p>The reference must have at most one target. [<specref ref="At_Most_One_Target"/>]</p>
</item>
<item>

                            <p>The reference <rfc2119>MUST</rfc2119> be consistent. [<specref ref="Consistent_References"/>]</p>
</item>
</olist>

</div3>
<div3 id="deref_XPath_Extension_Function">
<head>smlfn:deref() XPath Extension Function</head>

<p>The <code>deref()</code> function takes a node set of
elements and returns a node set consisting of element nodes
corresponding to the elements referenced by the input node set.  In
particular, for each SML reference R in the input node set the output
node set contains at most one element node.</p>
<p>Let I = input node set; that is, the set of nodes passed to the <code>deref()</code> function.</p>
<p>Let O = output node set; that is, the set of nodes returned by the <code>deref()</code> function.</p>

<p>The behavior of <code>deref()</code> function <rfc2119>MUST</rfc2119> satisfy the following constraints:</p>
<olist>
    <item>
<p>For each SML reference R in the input node set I:</p>
<olist>
    <item>
                                    <p>If the implementation recognizes no SML reference scheme used in the SML 
    reference R, then no element is added to O.</p>
</item>
    <item>
<p>If the implementation recognizes R as an instance of N supported reference schemes, 
    then <code>deref()</code> is not required to attempt to resolve all N schemes. 
    Its behavior in this case is implementation-defined and the set of reference schemes 
    that are actually attempted may be any subset of the recognized schemes. This is 
    subject to the following constraints:</p>
    <olist>
        <item>
                                    <p>If deref() doesn't attempt to resolve any reference scheme or if none of the attempted 
        reference schemes resolves, then no element is added to O.</p>
</item>
        <item>
                                    <p>If at least one of the attempted reference schemes resolves to more than one target 
        element, then 0 or 1 of the targets is added to O.</p>
</item>
        <item>
                                    <p>If one attempted reference scheme resolves to a target different from the target 
        resolved by another attempted reference scheme, then 0 or 1 of the targets is added to O.</p>
</item>
        <item>
                                    <p>If one attempted reference scheme resolves and another doesn't, then 0 or 1 of the 
        targets is added to O.</p>
</item>
        <item>
                                    <p>If none of the above is true (that is, all attempted reference schemes resolve to 
        the same one and only one target element, call it T), then one target element (namely, T) 
        is added to O, if it does not already exist in O.</p>
</item>
    </olist>
    </item>
</olist>
</item>
</olist>
<note>
                        <p>The above describes the behavior
required for a general XPath 1.0 deref() library function, and as such
exhibits several significant differences from the behavior required to
validate SML references during model validation.  First, it can be
used to successfully process instance documents whose SML model
validity is unknown or invalid, although the results in this case may
not be interoperable.  Second, since XPath 1.0 defines no way for a
function to signal erroneous input to its caller, the behavior here is
specified to return results for SML references that do not obey all of
the validity rules, e.g. a reference whose XPath expression evaluates
to more than one node.  As described in this section, such a function
would be insufficient to check the validity of SML references.
</p>

</note>
<p>Model validators MUST provide an implementation of the deref() XPath extension function.
 In addition to the above requirements for general deref() function implementations, 
 for each SML reference using recognized schemes, deref() in model validators 
 MUST attempt to resolve at least one of the recognized schemes.</p>


</div3>
</div2>

<div2 id="Reference_Schemes">
<head>SML Reference Schemes</head>

<p>An SML reference <rfc2119>MAY</rfc2119> be an instance of a variety of reference schemes. 
SML does
not mandate the use of any specific reference schemes. An SML reference scheme <rfc2119>MAY</rfc2119>
use child elements, attributes, both, or neither to capture the information necessary to identify 
the reference target. It is <rfc2119>OPTIONAL</rfc2119> that all elements in an SML model be reachable via an
SML reference. This will depend on the support defined by the chosen reference
scheme.
</p>
<p>
Although SML does not require the use of any specific 
scheme, it does specify how a reference <rfc2119>MUST</rfc2119> be 
represented when using SML-defined reference schemes. This specification defines
the <specref ref="URI_Reference_Scheme"/> for use in SML references. </p>

<p>
    An  SML reference scheme definition <rfc2119>MUST</rfc2119> specify all of the following:
</p>
    <olist>
        <item>

                        <p>
            The set of rules that, when satisfied, identify an SML reference as an
            instance of the scheme. An SML reference scheme definition <rfc2119>MAY</rfc2119>
            impose additional validity requirements on SML references recognized as instances of
            that scheme. <termref def="model_validator">Model validators</termref>
            <rfc2119>MUST NOT</rfc2119> apply such requirements 
            to SML references that are not instances of the corresponding reference scheme.
        </p>
</item>
        <item>
<p>The set of rules that, when evaluated, resolve the SML 
        reference to its target element node.</p>
        </item>
        <item>

                        <p>
            An assertion that states whether instances of the reference scheme are
            transformed to <termref def="target_complete_identifier">target-complete identifiers</termref>.  
            If they are transformed to <termref def="target_complete_identifier">target-complete identifiers</termref>, 
            the reference scheme definition MUST describe the transformation process.</p>
        </item>
    </olist>
<p>
    An SML reference scheme definition <rfc2119>MUST</rfc2119> specify all of the preceding
    items as they apply to valid instances of the SML reference scheme,
    and <rfc2119>MAY</rfc2119> specify them for other (invalid) instances.
</p>

<div3 id="URI_Reference_Scheme">
<head>SML URI Reference Scheme</head>

<p>The SML URI Reference Scheme is defined as follows:</p>
<olist>
    <item>

                            <p>An SML reference is identified as an instance of the SML URI Reference Scheme
    if and only if exactly one element information item whose <xspecref href="http://www.w3.org/TR/xml-infoset/#infoitem.attribute" xlink:type="simple" xlink:show="new" xlink:actuate="onRequest">[local name]</xspecref>
    is <code>uri</code> and whose <xspecref href="http://www.w3.org/TR/xml-infoset/#infoitem.attribute" xlink:type="simple" xlink:show="new" xlink:actuate="onRequest">[namespace name]</xspecref>
    is <code>http://www.w3.org/ns/sml</code> is present as a child of that reference element.</p>
    <p>An instance of the SML reference scheme is valid if it meets all of the
    following requirements.</p>
    <olist>
        <item>

                                    <p>
            The content of the <code>uri</code> element <rfc2119>MUST</rfc2119> be
            of type <code>xs:anyURI</code> as defined in the XML schema specification
            [<bibref ref="XSD2"/>].
        </p>
</item>
        <item>
<p>
            The fragment identifier (if present) <rfc2119>MUST</rfc2119> follow the syntax
            of one of the following.</p>
           <olist>
               <item>
                                    <p>
                                    <specref ref="SMLXPath1_Scheme"/>
                                    </p>
</item>
               <item>
                                    <p>
                                    <xspecref href="http://www.w3.org/TR/xptr-framework/#shorthand" xlink:type="simple" xlink:show="new" xlink:actuate="onRequest">Shorthand Pointer</xspecref>
                                    </p>
</item>
           </olist>
        </item>
    </olist>
    </item>
    <item>
        <p>An SML reference that is an instance of the SML URI Reference Scheme is resolved
        using the following steps:</p>
        <olist>
            <item>
<p>An XML document <term>D</term> is obtained as follows:</p>
            <olist>
                <item>
                                    <p>
                    If the URI reference is a same-document reference
                    as defined in the applicable URI RFC, 
                    then <term>D</term> is the document containing the SML reference.
                </p>
</item>
                
                <item>
                    <p>Otherwise, <term>D</term> is determined as follows:</p>
                    <olist>
                        <item>

                                    <p>If the URI reference is a relative reference, then let <term>U</term> 
                        be the result of resolving the reference using the 
                        [base URI] property [<bibref ref="XMLInfoset"/>] 
                        of the <code>&lt;sml:uri&gt;</code> element as the base URI. Otherwise, <term>U</term> 
                        is the URI reference itself. The computation of the [base URI]
                        property is implementation-defined.
                        </p>
</item>
                        <item>
                                    <p>Dereference <term>U</term> as defined in the applicable specifications.
                        If the document targeted 
                        by <term>U</term> is in the current SML model, then <term>D</term> is that document. Otherwise,
                        if the document is not in the current SML model, then the SML URI Reference Scheme instance 
                        is unresolved (and <term>D</term> has no value).
                        </p>
</item>
                    </olist>
                </item>
            </olist>
            <note>
                                    <p>
                As a result of the above definition, if the retrieved object is not of 
                XML media type or if it is not well-formed XML then, by definition, that
                object is not a document as defined by this specification. In this case, the
                SML reference scheme instance is unresolved.
            </p>
</note>
            </item>

            <item>
                                    <p>If no fragment component is present in the URI reference,
            the SML URI Reference Scheme instance resolves to the root element of
            <term>D</term>.</p>
</item>
            <item>
<p>If a fragment component  is present in the URI reference, then
            the appropriate case among the following applies:</p>
            <olist>
                <item>

                                    <p>
                    If the fragment component complies with the <code>smlxpath1()</code>
                    XPointer scheme syntax, then the reference target is obtained
                    by applying the fragment component to <term>D</term>,
                    as defined in section <specref ref="SMLXPath1_Scheme"/> .
                </p>
</item>
                <item>

                                    <p>
                    If the fragment component complies with the
                    <xspecref href="http://www.w3.org/TR/xptr-framework/#shorthand" xlink:type="simple" xlink:show="new" xlink:actuate="onRequest">Shorthand Pointer</xspecref>
                    syntax, then the appropriate case among the following applies:</p>
                    <olist>
                        <item>

                                    <p>
                            If a target <term>T</term> can be identified in <term>D</term> based on
                            the <xspecref href="http://www.w3.org/TR/xptr-framework/#term-sdi" xlink:type="simple" xlink:show="new" xlink:actuate="onRequest">XML-Schema-determined ID</xspecref>,
                            then the reference target is <term>T</term>.
                        </p>
</item>
                        <item>

                                    <p>
                            If a target in <term>D</term> cannot be identified based on
                            the <xspecref href="http://www.w3.org/TR/xptr-framework/#term-sdi" xlink:type="simple" xlink:show="new" xlink:actuate="onRequest">XML-Schema-determined ID</xspecref>,
                            then it is implementation-defined whether the reference target
                            in <term>D</term> is identified based on other criteria allowed for 
                            <xspecref href="http://www.w3.org/TR/xptr-framework/#shorthand" xlink:type="simple" xlink:show="new" xlink:actuate="onRequest">Shorthand Pointers</xspecref>.
                        </p>
</item>
                    </olist>
                </item>
            </olist>
            </item>
        </olist>
    </item>
    <item>

                            <p>
        Instances of the SML URI Reference Scheme are transformed to
        <termref def="target_complete_identifier">target-complete identifiers</termref>
        through standard URI processing, as described in the applicable URI RFC.
    </p>

</item>
</olist>

<p>The following example shows an SML reference that is an instance of the
SML URI Reference scheme. The reference targets the element with ID <code>targetId</code>
in document <code>target.xml</code>.</p>
<eg xml:space="preserve">
&lt;RefElement sml:ref="true"&gt;
    &lt;sml:uri&gt;target.xml#targetId&lt;/sml:uri&gt;
&lt;/RefElement&gt;
</eg>


<div4 id="SMLXPath1_Scheme">
<head>

<code>smlxpath1()</code> scheme</head>

<p>The <code>smlxpath1()</code> scheme is intended to be used with the
XPointer Framework [<bibref ref="XPTR"/>] to allow addressing of elements.
The <specref ref="URI_Reference_Scheme"/> uses it to encode fragment identifiers.</p>

<p>
    This section describes the syntax and semantics of the <code>smlxpath1()</code> scheme
    and the behavior of XPointer processors with respect to this scheme.
</p>

<olist>
    <item>
                                <p>Scheme name: <code>smlxpath1</code>
    </p>
</item>
    <item>
        <p>Scheme syntax using ABNF [<bibref ref="RFC2234"/>]:</p>
        <p>
                                    <code>SMLXPath1_Fragment_ID ::= 'smlxpath1' '(' SMLXPath1_SchemeData ')'</code>
</p>
        <p>
                                    <code>SMLXPath1_SchemeData  ::= XPath1.0_LocationPath</code>
</p>
        <p>where,</p>
        <p>

                                    <code>XPath1.0_LocationPath</code> is the <xspecref href="http://www.w3.org/TR/1999/REC-xpath-19991116#NT-LocationPath" xlink:type="simple" xlink:show="new" xlink:actuate="onRequest">LocationPath production</xspecref> defined in the XPath 1.0 specification [<bibref ref="XPath"/>].</p>
    </item>
    <item>
                                <p>The <code>deref()</code> XPath extension function <rfc2119>MUST NOT</rfc2119>
    be present in the expression evaluation context function library when
    processing the location path in <code>SMLXPath1_SchemeData</code>.
    </p>
</item>
    <item>
                                <p>Namespace Binding Context: The <code>smlxpath1()</code> scheme inherits
    the set of namespace bindings available to the parent <code>sml:uri</code> element.</p>
</item>
    <item>
        <p>
            For a given document <term>D</term>, 
            the element targeted by a scheme instance is obtained by applying the location path
            in <code>SMLXPath1_SchemeData</code> to the root element of <term>D</term>.
            The result <rfc2119>MUST</rfc2119> either be 1
            element node or be empty. Otherwise, the XPointer result is an error.
        </p>
        <note>

                                    <p>
            In the case of instances of the SML URI Reference scheme,
            <term>D</term> is the document resolved to by the non-fragment part of the
            URI reference, as defined in item 2.a in section
            <specref ref="URI_Reference_Scheme"/>.
        </p>

</note>
    </item>
</olist>
<p>The following example shows an SML reference that is an instance of the
SML URI Reference scheme. The reference targets the root element 
of the document <code>target.xml</code>.</p>
<eg xml:space="preserve">
&lt;RefElement sml:ref="true"&gt;
    &lt;sml:uri&gt;target.xml#smlxpath1(/*)&lt;/sml:uri&gt;
&lt;/RefElement&gt;
</eg>
</div4>

</div3>
</div2>
</div1>

<div1 id="SML_constraints">
<head>SML Constraints</head>

<div2 id="Constraints_on_References">
<head>Constraints on SML References</head>

<p>SML supports the following attributes for expressing constraints on SML references.</p>


<table border="1" cellspacing="0" cellpadding="5" id="Table3">
  <caption>Attributes</caption>
  <thead>
    <tr>
      <th rowspan="1" colspan="1">Name</th>
      <th rowspan="1" colspan="1">Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td rowspan="1" colspan="1">
                                <code>sml:acyclic</code>
</td>
      <td rowspan="1" colspan="1">Used to specify whether cycles are prohibited for an SML reference.</td>
    </tr>
    <tr>
      <td rowspan="1" colspan="1">
                                <code>sml:targetRequired</code>
</td>
      <td rowspan="1" colspan="1">Used to specify that an SML reference's target element is required
        to be present in the model.</td>
    </tr>    
    <tr>
      <td rowspan="1" colspan="1">
                                <code>sml:targetElement</code>
</td>
      <td rowspan="1" colspan="1">Used to constrain the name of the SML reference's target.</td>
    </tr>
    <tr>
      <td rowspan="1" colspan="1">
                                <code>sml:targetType</code>
</td>
      <td rowspan="1" colspan="1">Used to constrain the type of the SML reference's target.</td>
    </tr>
  </tbody>
</table>


<p>SML defines a new property for every Complex Type Definition schema component: 
<glist>
<gitem>
<label id="acyclic">{acyclic}</label> <def> <p>An <code>xs:boolean</code> value. Required.</p>
</def>
</gitem>
</glist>
</p>

<p>
The value of <termref def="acyclic">{acyclic}</termref> for <code>xs:anyType</code> is <code>false</code>.
</p>
<p>SML defines three new properties for every Element Declaration component: 
<glist>
<gitem>
<label id="targetRequired">{target required}</label> <def> <p>An <code>xs:boolean</code> value. Required. </p>
                            </def>
</gitem>
<gitem>
<label id="targetElement">{target element}</label> <def>
                                <p> An Element Declaration component. Optional. </p>
                            </def>
</gitem>
<gitem>
                            <label id="targetType">{target type}</label>
<def> <p> A Type Definition component. Optional. </p>
                            </def>
</gitem>
</glist>
</p>

<div3 id="sml_acyclic">
<head>sml:acyclic</head>

<p>

                        <code>sml:acyclic</code> is used to specify whether or not a cycle is allowed on 
instances of a complex type. <termref def="model_validator">Model validators</termref> 
<rfc2119>MUST</rfc2119> support the <code>sml:acyclic</code> attribute on any <code>&lt;xs:complexType&gt;</code> element in a schema document.
This attribute is of type <code>xs:boolean</code> and its <xspecref href="http://www.w3.org/TR/2004/REC-xmlschema-1-20041028/#key-vv" xlink:type="simple" xlink:show="new" xlink:actuate="onRequest">actual value</xspecref>
 can be either <code>true</code> or <code>false</code>. 
</p>

<div4 id="Acyclic_Mapping_From_Schema">
<head>SML Constraint Construction</head>
<p>The <termref def="acyclic">{acyclic}</termref> property value of a complex type definition is as specified 
by the appropriate case among the following:
</p>
<olist>
<item>

                                <p> If <code>sml:acyclic</code> is present, then <termref def="acyclic">{acyclic}</termref> 
has the actual value of this attribute.</p>
</item>
<item>

                                <p>Otherwise, if its {base type definition} is a complex type definition, 
then <termref def="acyclic">{acyclic}</termref> has the same value of 
<termref def="acyclic">{acyclic}</termref> as its {base type definition}.</p>
</item>
<item>

                                <p>Otherwise ({base type definition} is a simple type definition),
<termref def="acyclic">{acyclic}</termref> is false.</p>
</item>
</olist>
</div4>

<div4 id="Acyclic_Schema_Validity_Rules">
<head>Schema Component Rules</head>

<p>If a complex type definition <term>CT</term>'s {base type definition} is also a complex
type definition and has <termref def="acyclic">{acyclic}</termref> true, 
then <term>CT</term> <rfc2119>MUST</rfc2119> have <termref def="acyclic">{acyclic}</termref> true. </p>
</div4>

<div4 id="Acyclic_Instance_Validity_Rules">
<head>Instance Validity Rules</head>
<p>
If <term>CT</term> is a complex type definition with <termref def="acyclic">{acyclic}</termref> true, 
then instances of <term>CT</term> <rfc2119>MUST NOT</rfc2119> create cycles in the model. 
More precisely, the directed graph constructed in the following way <rfc2119>MUST</rfc2119> be acyclic:</p>
<olist>
<item>
                                <p>
The nodes in the graph are all the elements resolved to by SML references of
type <term>CT</term> or types derived from <term>CT</term>.
</p>
</item>
<item>
                                <p>If a node <term>N</term> in the graph is or contains an SML reference <term>R</term> of type <term>CT</term> or a type derived
from <term>CT</term>, and <term>R</term> resolves to <term>T</term> (which must also be a node in the graph), then an
arc is drawn from <term>N</term> to <term>T</term>.
</p>
</item>
</olist>
</div4>
</div3>

<div3 id="Constraints_on_Targets">
<head>Constraints on SML Reference Targets</head>

<p>SML defines three attributes: <code>sml:targetRequired</code>, 
<code>sml:targetElement</code>, and <code>sml:targetType,</code> for
constraining the target of an SML reference. These three attributes are
collectively called <code>sml:target*</code> attributes.
<termref def="model_validator">Model validators</termref> <rfc2119>MUST</rfc2119> 
support these attributes on all <code>xs:element</code> elements with a name attribute. The <code>sml:target*</code> constraints are attached to the element declaration schema component.
</p>


<div4 id="Target_Mapping_From_Schema">
<head>SML Constraint Construction</head>

<olist>
  <item>
                                <p>
<termref def="targetRequired">{target required}</termref> is as specified by the 
  appropriate case among the following:</p>
   <olist>
      <item>

                                    <p>If <code>sml:targetRequired</code> is present, then <termref def="targetRequired">{target required}</termref> 
      is the actual value of this attribute.</p>
</item>
      <item>

                                    <p>Otherwise if the element declaration has a {substitution group affiliation}, 
      then <termref def="targetRequired">{target required}</termref> is the same as that of 
      the {substitution group affiliation}.</p>
</item>
      <item>
                                    <p>Otherwise <termref def="targetRequired">{target required}</termref> is false.</p>
</item>            
   </olist>
  </item>
  <item>
                                <p>
<termref def="targetElement">{target element}</termref> is as specified by 
  the appropriate case among the following:</p>
   <olist>
      <item>

                                    <p>If <code>sml:targetElement</code> is present, then its actual value 
      <rfc2119>MUST</rfc2119> resolve to a global element declaration <term>G</term>, 
      and <termref def="targetElement">{target element}</termref> is <term>G</term>.</p>
</item>
      <item>

                                    <p>Otherwise if {substitution group affiliation} is present, then 
      <termref def="targetElement">{target element}</termref> is the same as 
      that of the {substitution group affiliation}.</p>
</item>
      <item>
                                    <p>Otherwise <termref def="targetElement">{target element}</termref> is absent.</p>
</item>            
   </olist>
  </item>  
  <item>
                                <p>
<termref def="targetType">{target type}</termref> is as specified by the 
  appropriate case among the following:</p>
   <olist>
      <item>

                                    <p>If <code>sml:targetType</code> is present, then its actual 
      value <rfc2119>MUST</rfc2119> resolve to a global type definition <term>T</term>,
      and <termref def="targetType">{target type}</termref> is <term>T</term>.</p>
</item>
      <item>

                                    <p>Otherwise if {substitution group affiliation} is present, 
      then <termref def="targetType">{target type}</termref> is the same as that 
      of the {substitution group affiliation}.</p>
</item>
      <item>
                                    <p>Otherwise <termref def="targetType">{target type}</termref> is absent.</p>
</item>            
   </olist>
  </item>  
</olist>

</div4>

<div4 id="Target_Schema_Validity_Rules">
<head>Schema Component Rules</head>

<p>
<termref def="model_validator">Model validators</termref> <rfc2119>MUST</rfc2119> 
enforce the following:</p>

<olist>
  <item>

                                <p>If a global element declaration <term>E</term> has a {substitution group affiliation} 
  <term>G</term>, then the value of <term>E</term>'s SML target constraint 
  property P (one of <termref def="targetRequired">{target required}</termref>, 
  <termref def="targetElement">{target element}</termref> or 
  <termref def="targetType">{target type}</termref>) <rfc2119>MUST</rfc2119> be a 
  valid restriction of the corresponding property of <term>G</term> as defined in 
  section <specref ref="Constraints_Valid_Restriction"/>.</p>
  </item>
  <item>

                                <p>If two element declarations <term>E1</term> and <term>E2</term> have the same {namespace name} 
  and {name} and they are both contained (directly, indirectly, or implicitly) in a content model 
  of a complex type, then <term>E1</term> and <term>E2</term> have the same <termref def="targetRequired">{target required}</termref>, 
  <termref def="targetElement">{target element}</termref>, and <termref def="targetType">{target type}</termref>.</p>
  </item> 
</olist>

<note>

<p>The above condition #2 on the use of <code>sml:target*</code>
attributes has been defined to reduce the implementation burden on 
<termref def="model_validator">model validators</termref>. Please refer to section <specref ref="Sml_Constraints_and_Derivation_Overview"/> for more information.</p>
</note>

</div4>


<div4 id="Target_Instance_Validity_Rules">
<head>Instance Validity Rules</head>

<p>If an element declaration <term>E</term> has <termref def="targetRequired">{target required}</termref> 
<code>true</code>, then each element instance of <term>E</term> that is also an 
SML reference <rfc2119>MUST</rfc2119> target some element in the model. 
That is, no instance of <term>E</term> can be a null or unresolved SML reference.</p>

<p>
If an element declaration <term>E</term> has <termref def="targetElement">{target element}</termref> 
<term>TE</term>, then each element instance of <term>E</term> that is also a resolved SML reference
<rfc2119>MUST</rfc2119> target an element that is an instance of <term>TE</term> or an instance 
of some global element declaration in the substitution group of <term>TE</term>.
</p>

<p>
If an element declaration <term>E</term> has <termref def="targetType">{target type}</termref> 
<term>TT</term>, then each element instance of <term>E</term> that is also a resolved SML reference 
<rfc2119>MUST</rfc2119> target an element whose [type definition] is <term>TT</term>
or a type derived from <term>TT</term>.
</p>
</div4>

</div3>

<div3 id="constraints_summary">
<head>SML Reference Constraints Summary (Non-Normative)</head>

<p>The effect of the above instance validation rules is 
summarized in the following table. 
</p>

<table border="1" cellspacing="0" cellpadding="5" id="Table_TargetConstraintsAndRefCategories">
  <caption>Target Constraints and SML Reference Categories.</caption>
  <thead>
    <tr>
      <th rowspan="1" colspan="1">Reference Category</th>
      <th rowspan="1" colspan="1">
                                    <code>Acyclic</code>
</th>
      <th rowspan="1" colspan="1">
                                    <code>targetRequired</code>
</th>
      <th rowspan="1" colspan="1">
                                    <code>targetElement</code>
</th>
      <th rowspan="1" colspan="1">
                                    <code>targetType</code>
</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td rowspan="1" colspan="1">Non-reference</td>
      <td rowspan="1" colspan="1">Satisfied</td>
      <td rowspan="1" colspan="1">Satisfied</td>
      <td rowspan="1" colspan="1">Satisfied</td>
      <td rowspan="1" colspan="1">Satisfied</td>
    </tr>
    <tr>
      <td rowspan="1" colspan="1">Null</td>
      <td rowspan="1" colspan="1">Satisfied</td>
      <td rowspan="1" colspan="1">Violated</td>
      <td rowspan="1" colspan="1">Satisfied</td>
      <td rowspan="1" colspan="1">Satisfied</td>
    </tr>
    <tr>
      <td rowspan="1" colspan="1">Unresolved</td>
      <td rowspan="1" colspan="1">Satisfied</td>
      <td rowspan="1" colspan="1">Violated</td>
      <td rowspan="1" colspan="1">Satisfied</td>
      <td rowspan="1" colspan="1">Satisfied</td>
    </tr>
    <tr>
      <td rowspan="1" colspan="1">Resolved</td>
      <td rowspan="1" colspan="1">Check</td>
      <td rowspan="1" colspan="1">Satisfied</td>
      <td rowspan="1" colspan="1">Check</td>
      <td rowspan="1" colspan="1">Check</td>
    </tr>
  </tbody>
</table>

<p>"Check" in the table above means that the appropriate constraint
    must be evaluated. </p>
<p>The constraints described above can be useful even on element declarations
whose instances are not necessarily SML references, because the decision about
whether to include a constraint and the decision about whether to make the
element an SML reference can be made independently - some choices made by the
schema author, other choices made by the instance document author.
</p>
</div3>

</div2>

<div2 id="Identity_Constraints">
<head>SML Identity Constraints</head>

<p>XML Schema supports the definition of uniqueness and reference 
constraints through <code>xs:key</code>, <code>xs:unique</code>, and
<code>xs:keyref</code> elements. However, the scope of these constraints is
restricted to a single document. SML defines analogs for these constraints,
whose scope extends to multiple documents by allowing them to traverse
<termref def="reference">SML references</termref>.</p>

<p>
<termref def="model_validator">Model validators</termref> <rfc2119>MUST</rfc2119> support the
following elements for defining SML identity constraints across SML references,
as child elements of <code>xs:element/xs:annotation/xs:appinfo</code> where 
the <code>xs:element</code> has a name attribute.</p>

<table border="1" cellspacing="0" cellpadding="5" id="Table5">
  <thead>
    <tr>
      <th rowspan="1" colspan="1">Name</th>
      <th rowspan="1" colspan="1">Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td rowspan="1" colspan="1">
                                <code>sml:key</code>
</td>
      <td rowspan="1" colspan="1">Similar to <code>xs:key</code> except that the selector and
        field XPath expression can use the <code>smlfn:deref</code> function</td>
    </tr>
    <tr>
      <td rowspan="1" colspan="1">
                                <code>sml:unique</code>
</td>
      <td rowspan="1" colspan="1">Similar to <code>xs:unique</code> except that the selector and
        field XPath expression can use the <code>smlfn:deref</code> function</td>
    </tr>
    <tr>
      <td rowspan="1" colspan="1">
                                <code>sml:keyref</code>
</td>
      <td rowspan="1" colspan="1">Similar to <code>xs:keyref</code> except that the selector and
        field XPath expression can use the <code>smlfn:deref</code> function</td>
    </tr>
  </tbody>
</table>

<p>Appendix <specref ref="Model_Definition_Document_Sample"/>  and
Appendix <specref ref="Identity_Constraints_Example"/> have examples that
show how SML identity constraints are defined.
</p>

<p>
    SML identity constraints are attached to the element declaration
    schema component. SML defines a new property for every element declaration
    schema component:
<glist>
<gitem>
<label id="id_constr_def">{SML identity-constraints definitions}</label>
<def>
                                <p> A set of SML identity constraint 
definitions components, which have the same set of properties as 
XML Schema identity constraint definitions.</p>
</def>
</gitem>
</glist>
</p>

<div3 id="Identity_Constraints_Syntax_Semantics">
<head>Syntax and Semantics</head>

<p>
Names of all SML identity constraint definitions exist in a single symbol space,
which is disjoint from any symbol space of XML Schema components.
</p>

<div4 id="Identity_Constraints_Mapping_from_Schema">
<head>SML Constraint Construction</head>

<p>
For each <code>sml:key</code>, <code>sml:unique</code>, or <code>sml:keyref</code> 
element without the <code>ref</code> attribute specified, 
<termref def="id_constr_def">{SML identity-constraints definitions}</termref> 
contains a component corresponding to this element, as specified in 
section <loc href="http://www.w3.org/TR/xmlschema-1/#cIdentity-constraint_Definitions" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">3.11 Identity-constraint Definitions</loc> 
of the XML Schema specification [<xspecref href="#XSD1" xlink:type="simple" xlink:show="new" xlink:actuate="onRequest">XML Schema Structures</xspecref>]), 
where <code>sml:selector</code> and <code>sml:field</code> elements 
are used in place of <code>xs:selector</code> and <code>xs:field</code>.
</p>

<p>
For each <code>sml:key</code>, <code>sml:unique</code>, or <code>sml:keyref</code> 
element with the <code>ref</code> attribute specified, 
<termref def="id_constr_def">{SML identity-constraints definitions}</termref>
contains the component resolved to by the actual value of 
the <code>ref</code> attribute, with the following conditions:
</p>
<olist>
  <item>
  <p>The name attribute <rfc2119>MUST NOT</rfc2119> be specified.</p>
  </item>
  <item>
  <p>The <code>sml:selector</code> and <code>sml:field</code> child 
  elements <rfc2119>MUST NOT</rfc2119> be specified.</p>
  </item>
  <item>
  <p>If the element is <code>sml:key</code>, then the value of <code>ref</code> 
  attribute <rfc2119>MUST</rfc2119> resolve to an SML key constraint.</p>
  </item>
  <item>
  <p>If the element is <code>sml:unique</code>, then the value of the <code>ref</code>
  attribute <rfc2119>MUST</rfc2119> resolve to an SML unique constraint.
  </p>
  </item>
  <item>
  <p>If element is <code>sml:keyref</code>, then the value of the <code>ref</code> 
  attribute <rfc2119>MUST</rfc2119> resolve to an SML keyref constraint, 
  and the <code>refer</code> attribute <rfc2119>MUST NOT</rfc2119> be specified.
  </p>
  </item>
  
</olist>

<p>In addition to SML identity constraints obtained from the above explicit 
definitions or references, if an element declaration <term>S</term> has 
a {substitution group affiliation} <term>G</term>, then its 
<termref def="id_constr_def">{SML identity-constraints definitions}</termref>
also contains members of <termref def="id_constr_def">{SML identity-constraints definitions}</termref> 
of <term>G</term>.
</p>

</div4>

<div4 id="Identity_Constraints_Schema_Validity_Rules">
<head>Schema Component Rules</head>

<olist>
  <item>
    <p>
     <code>sml:selector</code> XPath expression has the same syntax as that defined in the 
     XML Schema identity constraint selector XPath syntax with one exception. 
     The <code>sml:selector</code> XPath <rfc2119>MAY</rfc2119> use <code>smlfn:deref()</code> functions, 
     with function calls nested to any depth, at the beginning of the expression. The XML Schema identity constraint 
     selector Path production is amended to support this requirement as defined below.
    </p>

<eg xml:space="preserve">
Path ::= ('.//')? Step ( '/' Step)* | DerefExpr
DerefExpr ::= NCName ':' 'deref' '(' Step ('/'Step)* ')' ('/'Step)* |
              NCName ':' 'deref' '(' DerefExpr ')' ('/'Step)*
</eg>
  </item>
  <item>

<p>
     <code>sml:field</code> XPath expression has the same syntax as that defined in the 
     XML Schema identity constraint field XPath syntax with one exception. 
     The <code>sml:field</code> XPath <rfc2119>MAY</rfc2119> use <code>smlfn:deref()</code> functions, 
     with function calls nested to any depth, at the beginning of the expression. The XML Schema identity constraint 
     field Path production is amended to support this requirement as defined below.
  </p>
  <eg xml:space="preserve">
Path ::= ('.//')? ( Step '/')* ( Step | '@' NameTest ) |
         DerefExpr ('/' '@' NameTest)?
DerefExpr ::= NCName ':' 'deref' '(' Step ('/'Step)* ')' ('/'Step)* |
              NCName ':' 'deref' '(' DerefExpr ')' ('/'Step)*
</eg>
  </item>
  <item>
<p>The <termref def="id_constr_def">{SML identity-constraints definitions}</termref>
  of an element declaration <rfc2119>MUST NOT</rfc2119> contain two identity constraints with the same name.</p>
<note>
<p>This could happen if the ref attribute resolves to 
an identity constraint already contained in the same element declaration’s 
<termref def="id_constr_def">{SML identity-constraints definitions}</termref>.</p>
</note> 
  </item>
  <item>

                                <p>If a global element declaration <term>E</term> has a {substitution group affiliation} 
  <term>G</term>, then the value of <term>E</term>'s 
  <termref def="id_constr_def">{SML identity-constraints definitions}</termref> 
  property <rfc2119>MUST</rfc2119> be a valid restriction of the value of the 
  corresponding property 
  of <term>G</term> as defined in section <specref ref="Constraints_Valid_Restriction"/>.</p>
  </item>
  <item>

<p>If two element declarations <term>E1</term> and <term>E2</term> have the 
  same {namespace name} and {name} and they are both contained 
  (directly, indirectly, or implicitly) in a content model of a complex type, 
  then <term>E1</term> and <term>E2</term> <rfc2119>MUST</rfc2119> have 
  the same set of <termref def="id_constr_def">{SML identity-constraints definitions}</termref>.</p>
  <note>

<p>This rule is defined to reduce the implementation burden 
  for model validators. Please refer to section <specref ref="Sml_Constraints_and_Derivation_Overview"/> for more information.</p>
  </note>
  </item>
</olist>
</div4>

<div4 id="Identity_Constraints_Instance_Validity_Rules">
<head>Instance Validity Rules</head>

<p>Validation rules for SML identity constraints are the same as specified in 
section <loc href="http://www.w3.org/TR/xmlschema-1/#cIdentity-constraint_Definitions" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">3.11 Identity-constraint Definitions</loc> 
of the XML Schema specification [<xspecref href="#XSD1" xlink:type="simple" xlink:show="new" xlink:actuate="onRequest">XML Schema Structures</xspecref>]), 
with the addition of support for the <code>smlfn:deref()</code> function.</p>

</div4>
</div3>

</div2>


<div2 id="Constraints_Valid_Restriction">
<head>Valid Restriction of SML Constraint Values</head>
<p>Let BV = value of SML constraint property P (one of <termref def="targetRequired">{target required}</termref>, <termref def="targetElement">{target element}</termref>, <termref def="targetType">{target type}</termref> or <termref def="id_constr_def">{SML identity-constraints definitions}</termref>).
</p>
<p>Let RV = value that restricts BV.</p>

<p>For RV to be a valid restriction of BV, the appropriate case among the following <rfc2119>MUST</rfc2119> be true.
</p>
<olist>
    <item>
        <p>For <termref def="targetRequired">{target required}</termref>, the appropriate case among the following applies.
        </p>
        <olist>
            <item>
                                <p>If BV is true, RV is true.</p>
</item>
            <item>
                                <p>If BV is false, RV is either true or false.</p>
</item>
        </olist>
    </item>
    <item>
        <p>For <termref def="targetElement">{target element}</termref>, one of the following applies.
        </p>
        <olist>
            <item>
                                <p>RV is same as BV.</p>
</item>
            <item>
                                <p>RV is in the substitution group of BV.</p>
</item>
        </olist>
    </item>
    <item>
        <p>For <termref def="targetType">{target type}</termref>, one of the following applies.
        </p>
        <olist>
            <item>
                                <p>RV is same as BV.</p>
</item>
            <item>
                                <p>RV is a type derived from BV.</p>
</item>
        </olist>
    </item>
    <item>
        <p>For <termref def="id_constr_def">{SML identity-constraints definitions}</termref>, one of the following applies.
        </p>
        <olist>
            <item>
<p>RV is same as BV. That is, all of the following is true.</p>
            <olist>
                <item>
                                    <p>The number of entries in RV is same as the number of entries in BV.
                </p>
</item>
                <item>
                                    <p>For each entry in BV, there exists an entry in RV with the same qualified name ({name} + {target namespace}).
                </p>
</item>
            </olist>
            </item>
            <item>
                                <p>RV is a superset of BV. That is, RV has all of the entries
            from BV as defined in the previous item and it has one or more
            additional entries.</p>
</item>
        </olist>
    </item>
</olist>

</div2>

<div2 id="SML_Constraints_and_Complex_Type_Derivation">
<head>SML Constraints and Complex Type Derivation</head>

<div3 id="Sml_Constraints_and_Derivation_Overview">
<head>Overview of SML Constraint Processing and Complex Type Derivation</head>
<p>This section is non-normative.</p>

<p>For a complex type D derived from its {base type definition} B, if an element
declaration ED is included in D and an element declaration EB is included in B,
and ED and EB satisfy the "NameAndTypeOK" constraint, then the SML constraints
(target* and SML identity constraints) applicable to ED must be
</p>
<olist>
    <item>
                            <p>the same as those on EB in case of derivation by extension, and
    </p>
</item>
    <item>
                            <p>the same or more restrictive compared to those on EB in case of derivation by restriction.
    </p>

</item>
</olist>
<p>SML defines this behavior to ensure that one cannot get rid of SML
constraints on elements in a complex type by simply deriving another
type from that type.
</p>

<p>Enforcing this condition across derivation by restriction would
require an implementation to match a restricting particle to the
corresponding restricted particle in order to evaluate condition 2
above. This level of support is not provided by most XML Schema
frameworks; thus most SML validators would otherwise need to duplicate
large parts of XML Schema's compilation logic to verify consistent
usage of SML constraints across derivation by restriction. In order to
reduce this implementation burden on model validators, SML requires
that all element declarations with a given name that are included in a
complex type definition must have the same SML constraint value. This
allows model validators to find the restricted particle for a
restricting particle using a simple name match.
</p>

<p>This also means that the value of a given SML constraint applicable
to all element declarations of a given name in complex type definition
can be logically viewed as available at a single place, for example in
a property attached to that complex type, rather than being scattered
across element declarations in that type. The next section uses this
logical view because it makes it easier to understand and formally
define SML constraint behavior across complex type derivation.
</p>
</div3>

<div3 id="Constraints_Definition">
<head>Formal Definition</head>

<div4 id="Constraints_Properties">
<head>Properties</head>
<p>SML defines four properties for every complex type definition schema component CT. 
<glist>
    <gitem>
        <label id="targetRequiredConstraintList">{target required constraint list}</label>
        <def>
            <p>A list of (qname, value) pairs, where,</p>
            <olist>
                <item>
                                    <p>qname is a qualified name ({namespace name} + {name}).</p>
</item>
                <item>

                                    <p>value is the value of a <termref def="targetRequired">{target required}</termref> property.</p>

</item>
            </olist>
        </def>
    </gitem>
    <gitem>
        <label id="targetElementConstraintList">{target element constraint list}</label>
        <def>
            <p>A list of (qname, value) pairs, where,</p>
            <olist>
                <item>
                                    <p>qname is a qualified name ({namespace name} + {name}).</p>
</item>
                <item>

                                    <p>value is the value of a <termref def="targetElement">{target element}</termref> property.</p>

</item>
            </olist>
        </def>
    </gitem>
    <gitem>
        <label id="targetTypeConstraintList">{target type constraint list}</label>
        <def>
            <p>A list of (qname, value) pairs, where,</p>
            <olist>
                <item>
                                    <p>qname is a qualified name ({namespace name} + {name}).</p>
</item>
                <item>

                                    <p>value is the value of a <termref def="targetType">{target type}</termref> property.</p>

</item>
            </olist>
        </def>
    </gitem>
    <gitem>
        <label id="identityConstraintList">{identity constraint list}</label>
        <def>
            <p>A list of (qname, value) pairs, where,</p>
            <olist>
                <item>
                                    <p>qname is a qualified name ({namespace name} + {name}).</p>
</item>
                <item>

                                    <p>value is the value of a <termref def="id_constr_def">{SML identity-constraints definitions}</termref> property.</p>

</item>
            </olist>
        </def>
    </gitem>
</glist>
</p>
<p>The value of the above 4 properties for <code>xs:anyType</code> is empty.</p>
</div4>

<div4 id="Constraints_Derivation_Rules">
<head>SML Constraint Construction</head>
<p>Let</p>
<ulist>
    <item>
                                <p>CT = A complex type definition.
    </p>
</item>
    <item>
                                <p>C = SML constraint (one of targetRequired, targetElement, targetType, SML identity constraint).
    </p>
</item>
    <item>

                                <p>P = A property of CT corresponding to constraint C (one of <termref def="targetRequiredConstraintList">{target required constraint list}</termref>, 
<termref def="targetElementConstraintList">{target element constraint list}</termref>, 
<termref def="targetTypeConstraintList">{target type constraint list}</termref>, 
<termref def="identityConstraintList">{identity constraint list}</termref>).
    </p>
</item>
    <item>
                                <p>V = The value of P, a list of (qname, value) pairs.
    </p>
</item>
    <item>
                                <p>ED = An element declaration contained in CT.
    </p>
</item>
    <item>

                                <p>PED = A property of ED corresponding to constraint C (one of
    <termref def="targetRequired">{target required}</termref>,
    <termref def="targetElement">{target element}</termref>,
    <termref def="targetType">{target type}</termref>,
    <termref def="id_constr_def">{SML identity-constraints definitions}</termref>).
    </p>

</item>
</ulist>

<p>Property P is assigned value V as defined below: 
</p>
<olist>
    <item>
        <p>For each element declaration ED, with qualified name qn, contained  in CT:</p>
        <olist>
            <item>
                <p>If ED does not have constraint C, that is, the value of PED
                is absent (or false in case of targetRequired), then skip ED.</p>
            </item>
            <item>
                <p>Otherwise, if there is already an entry in V for qn, then skip ED.</p>
                <note>
                    <p>If the value of the existing entry is different from
                    the value of PED then it is treated as a schema validation
                    error as defined in
                    section <specref ref="Target_Schema_Validity_Rules"/> and
                    section <specref ref="Identity_Constraints_Schema_Validity_Rules"/>.
                    </p>
                </note>
            </item>
            <item>
                <p>Otherwise, the entry (qn, value of PED) is added to the list V.</p>
            </item>
        </olist>
    </item>
    <item>
        <p>The appropriate case among the following applies:</p>
        <olist>
            <item>
                <p>If CT is derived by extension from a simple type definition then value V is empty.</p>
            </item>
            <item>
                <p>If CT is derived by extension from a complex type definition BT:</p>
                <p>The initial value of V is computed as defined in list item 1 above and then,</p>
                <p>For each entry (qn, v<sub>b</sub>) in the value of P in BT:</p>
                <olist>
                    <item>
                        <p>If V has an entry (qn, v<sub>c</sub>) present, then ensure that v<sub>c</sub> is same as v<sub>b</sub>. If it is not same, then it is treated as a schema validation error.</p>
                    </item>
                    <item>
                        <p>If V does not have any entry (qn, v<sub>c</sub>) present, then copy (qn, v<sub>b</sub>) into V.</p>
                    </item>
                </olist>
            </item>
            <item>
                <p>If CT is derived by restriction from a complex type definition BT:</p>
                <p>The initial value of V is computed as defined in list item 1 above and then,</p>
                <p>For each entry (qn, v<sub>b</sub>) in the value of P in BT:</p>
                <olist>
                    <item>
                        <p>If V has an entry (qn, v<sub>c</sub>) present, then ensure that v<sub>c</sub> is a valid restriction of v<sub>b</sub> as defined in section <specref ref="Constraints_Valid_Restriction"/>. If it is not, then it is treated as a schema validation error.</p>
                    </item>
                    <item>
                        <p>If V does not have any entry (qn, v<sub>c</sub>) present, then copy (qn, v<sub>b</sub>) into V.</p>
                        <p/>
                    </item>
                </olist>
            </item>
        </olist>
    </item>
</olist>
</div4>

<div4 id="Constraints_Instance_Validity_Rules">
<head>Instance Validity Rules</head>
<p>Let,</p>
<ulist>
    <item>
                                <p>CT = the complex type of element declaration ED.
    </p>
</item>
    <item>
                                <p>E = an instance of ED.
    </p>
</item>
    <item>
                                <p>C = a child element of E.
    </p>

</item>
</ulist>
<p>If C matches an element declaration contained in CT and if one or
more of CT's constraint properties, defined in <specref ref="Constraints_Properties"/>, contain an
entry matching C's qualified name ({namespace name} + {name}) then the
value of each of those entries is used for evaluating the
corresponding constraint on C, as defined in section <specref ref="Target_Instance_Validity_Rules"/> and section
<specref ref="Identity_Constraints_Instance_Validity_Rules"/>, as if the matching element declaration has the corresponding constraint with that value.
</p>
<note>
<p>One way for constraints to be embedded in element 
declarations or type definitions in a schema is for constraint element to be 
included in a schema document, embedded at the appropriate locations within the 
<code>xs:element</code> or <code>xs:complexType</code> elements which describe 
the element declaration or type definition. </p>

<p>Element declarations and type definitions created by other means can, however, 
also have constraints embedded within the {application information} of 
their {annotation} properties. How such embedding is accomplished is outside 
the scope of this specification and is likely to vary among <termref def="model">model processors</termref>.</p>
</note>
</div4>


</div3>
</div2>

</div1>

<div1 id="SML_Rules">
<head>Rules</head>
<p>XML Schema supports a number of built-in grammar-based constraints but it does
not support a language for defining arbitrary rules for constraining the
structure and content of documents. Schematron [<bibref ref="Schematron"/>] is an ISO/IEC
standard for defining assertions concerning a set of XML documents. SML uses
Schematron to add support for additional model constraints not supported in XML
Schema.</p>

<div2 id="Rules_Informal_Description">
<head>Informal Description (Non-Normative)</head>

<p>This section assumes that the reader is familiar with
Schematron concepts; the Schematron standard is documented in [<bibref ref="Schematron"/>] and [<bibref ref="intro_schematron"/>, <bibref ref="improving_schematron"/>]
are good tutorials on an older version of Schematron.</p>

<p>Constraints can be specified using the
<code>sch:assert</code> and <code>sch:report</code> elements from Schematron.
 The following example uses <code>sch:assert</code> elements to specify two
constraints:</p>
<olist>
  <item>
<p>An IPv4 address must have four bytes</p>
  </item>
  <item>
<p>An IPv6 address must have sixteen bytes</p>
  </item>
</olist>
<eg xml:space="preserve">
&lt;xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:x-example:IPAddress"&gt;
    &lt;xs:simpleType  name="IPAddressVersionType"&gt;
        &lt;xs:restriction base="xs:string" &gt;
            &lt;xs:enumeration value="V4" /&gt;
            &lt;xs:enumeration value="V6" /&gt;
        &lt;/xs:restriction&gt;
    &lt;/xs:simpleType&gt;

    &lt;xs:complexType name="IPAddress"&gt;
        &lt;xs:annotation&gt;
            &lt;xs:appinfo&gt;
                &lt;sch:schema xmlns:sch="http://purl.oclc.org/dsdl/schematron"&gt;
                   &lt;sch:ns prefix="tns" uri="urn:x-example:IPAddress" /&gt;
                   &lt;sch:pattern id="Length"&gt;
                      &lt;sch:rule context="."&gt;
                         &lt;sch:assert test="tns:version != 'V4' or count(tns:address) = 4"&gt;
                              A v4 IP address must have 4 bytes.
                         &lt;/sch:assert&gt;
                         &lt;sch:assert test="tns:version != 'V6' or count(tns:address) = 16"&gt;
                              A v6 IP address must have 16 bytes.
                         &lt;/sch:assert&gt;
                      &lt;/sch:rule&gt;
                   &lt;/sch:pattern&gt;
                &lt;/sch:schema&gt;            
            &lt;/xs:appinfo&gt;
        &lt;/xs:annotation&gt;
        &lt;xs:sequence&gt;
            &lt;xs:element name="version" type="tns:IPAddressVersionType" /&gt;
            &lt;xs:element name="address" type="xs:byte" minOccurs="4" maxOccurs="16" /&gt;
        &lt;/xs:sequence&gt;
    &lt;/xs:complexType&gt;
&lt;/xs:schema&gt;     
</eg>

<p>A <termref def="schematron_constraint">Schematron constraint</termref> embedded in the 
<code>xs:annotation/xs:appinfo</code> element for a complex
type definition or an element declaration is applicable to all instances of
the complex type or element. In the above example, the pattern 
<code>Length</code> (which is a part of the containing Schematron constraint) 
is applicable for all elements whose
type is <code>IPAddress</code> or a derived type
of <code>IPAddress</code>. A <code>pattern</code> element contains one or
more <code>sch:rule</code> elements and a single <code>sch:rule</code> element contains 
one or more <code>assert</code> and/or <code>report</code> elements. Each <code>sch:rule</code> element specifies its context using the 
<code>context</code> attribute. This context expression 
is evaluated in the context of each applicable element and results in an
element node set for which the assert and report <code>test</code> expressions contained in
the <code>sch:rule</code> element are evaluated. The <code>context</code> expression is defined as an XSLT Pattern. 
This means that the <code>smlfn:deref</code> function may not be used in the 
location path of a <code>context</code> expression.</p>

<p>In the above example, 
<code>context="."</code>. Therefore the two assert
expressions are evaluated in the context of each applicable element; i.e.,
each element of type <code>IPAddress</code>. The
<code>test</code> expression for an <code>assert</code> is a
boolean expression, and the <code>assert</code> is
violated (or fires) if its <code>test</code> expression evaluates 
to false. A <code>report</code> is violated (or
fires) if its <code>test</code> expression evaluates to true. Thus, an 
<code>assert</code> can be converted to a 
<code>report</code> by simply negating its test expression.
The following example uses <code>report</code> elements to represent the IP address constraints of the previous
example:</p>
<eg xml:space="preserve">
&lt;xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:x-example:IPAddress"&gt;
    &lt;xs:simpleType  name="IPAddressVersionType"&gt;
        &lt;xs:restriction base="xs:string"&gt;
           &lt;xs:enumeration value="V4"/&gt;
           &lt;xs:enumeration value="V6"/&gt;
        &lt;/xs:restriction&gt;
    &lt;/xs:simpleType&gt;

    &lt;xs:complexType name="IPAddress"&gt;
        &lt;xs:annotation&gt;
            &lt;xs:appinfo&gt;
                &lt;sch:schema xmlns:sch="http://purl.oclc.org/dsdl/schematron"&gt;
                    &lt;sch:ns prefix="tns" uri="urn:x-example:IPAddress" /&gt;
                    &lt;sch:pattern id="Length"&gt;
                        &lt;sch:rule context="."&gt;
                            &lt;sch:report test="tns:version = 'V4' and count(tns:address)!= 4"&gt;
                                A v4 IP address must have 4 bytes.
                            &lt;/sch:report&gt;
                            &lt;sch:report test="tns:version = 'V6' and count(tns:address) != 16"&gt;
                                A v6 IP address must have 16 bytes.
                            &lt;/sch:report&gt;
                        &lt;/sch:rule&gt;
                    &lt;/sch:pattern&gt;
                &lt;/sch:schema&gt;            
            &lt;/xs:appinfo&gt;
        &lt;/xs:annotation&gt;
        &lt;xs:sequence&gt;
            &lt;xs:element name="version" type="tns:IPAddressVersionType" /&gt;
            &lt;xs:element name="address" type="xs:byte" minOccurs="4" maxOccurs="16" /&gt;
        &lt;/xs:sequence&gt;
    &lt;/xs:complexType&gt;
&lt;/xs:schema&gt;     
</eg>

<p>If a <code>sch:assert</code> or <code>sch:report</code> is violated, 
the violation is reported together with the specified message. 
The message can include substitution strings based on
XPath expressions. These can be specified using the
<code>sch:value-of</code> element. The following example
uses the <code>sch:value-of</code> element to
include the number of specified address bytes in the message:</p>
<eg xml:space="preserve">
&lt;sch:assert test="tns:version != 'v4' or count(tns:address) = 4"&gt;
     A v4 IP address must have 4 bytes instead of the specified
     &lt;sch:value-of select="string(count(tns:address))"/&gt; bytes.
&lt;/sch:assert&gt;
</eg>

<p>In addition to being embedded in complex
type definitions, constraints can also be embedded in global element
declarations. Such constraints are evaluated for each instance element
corresponding to the global element declaration. Consider the following
example:</p>

<eg xml:space="preserve">
&lt;xs:element name="StrictUniversity" type="tns:UniversityType"&gt;
    &lt;xs:annotation&gt;
        &lt;xs:appinfo&gt;
            &lt;sch:schema xmlns:sch="http://purl.oclc.org/dsdl/schematron"&gt;
                &lt;sch:ns prefix="u" uri="http://www.university.example.org/ns" /&gt;
                &lt;sch:ns prefix="smlfn"  
                        uri="http://www.w3.org/ns/sml-function"/&gt;
                &lt;sch:pattern id="StudentPattern"&gt;
                    &lt;sch:rule context="u:Students/u:Student"&gt;
                        &lt;sch:assert test="smlfn:deref(.)[starts-with(u:ID,'99')]"&gt;
                            The specified ID &lt;sch:value-of select="string(u:ID)"/&gt;
                             does not begin with 99.
                        &lt;/sch:assert&gt;
                        &lt;sch:assert test="count(u:Courses/u:Course)&gt;0"&gt;
                            The student &lt;sch:value-of select="string(u:ID)"/&gt; must be enrolled
                            in at least one course.
                        &lt;/sch:assert&gt;
                    &lt;/sch:rule&gt;
                &lt;/sch:pattern&gt;
             &lt;/sch:schema&gt;
         &lt;/xs:appinfo&gt;
    &lt;/xs:annotation&gt;
&lt;/xs:element&gt;
</eg>

<p>The <code>sch:rule</code> elements contained in 
 <code>StudentPattern</code> are applicable to all element
instances of the <code>StrictUniversity</code> global element declaration. For each
 <code>StrictUniversity</code> element, the XPath expression
specified as the value of the <code>context</code> attribute is evaluated to return a node set, and the test
expressions for the two asserts are evaluated for each node in this node set.
 Thus, these two asserts verify the following conditions for
each instance of <code>StrictUniversity</code>.</p>
<olist>
  <item>
<p>The ID of each student must begin with '99'.</p>
  </item>
  <item>

<p>Each student must be enrolled in at least one course.</p>
  </item>
</olist>

<p>Schematron patterns can be authored in separate rule documents 
that are then bound to a set of documents in the model.  
</p>
<p>The following example shows the constraints for 
<code>StrictUniversity</code> expressed in a separate document:</p>
<eg xml:space="preserve">
&lt;?xml version="1.0" encoding="utf-8" ?&gt;
&lt;sch:schema xmlns:sch="http://purl.oclc.org/dsdl/schematron"&gt;
    &lt;sch:ns prefix="u" uri="http://www.university.example.org/ns" /&gt;
    &lt;sch:ns prefix="smlfn" uri="http://www.w3.org/ns/sml-function"/&gt;
    &lt;sch:pattern id="StudentPattern"&gt;
        &lt;sch:rule context="u:StrictUniversity/u:Students/u:Student"&gt;
            &lt;sch:assert test="smlfn:deref(.)[starts-with(u:ID,'99')]"&gt;
                The specified ID &lt;sch:value-of select="string(u:ID)"/&gt;
                does not begin with 99.
            &lt;/sch:assert&gt;
            &lt;sch:assert test="count(u:Courses/u:Course)&gt;0"&gt;
                The student &lt;sch:value-of select="string(u:ID)"/&gt; must be enrolled
                in at least one course.
            &lt;/sch:assert&gt;
        &lt;/sch:rule&gt;
    &lt;/sch:pattern&gt;
&lt;/sch:schema&gt;
</eg>

<p>
The binding of the rule document containing the <code>StudentPattern</code>
pattern to documents that may contain instances of <code>StrictUniversity</code>
element is implementation-defined.
</p>


</div2>

<div2 id="Rule_Support">
  <head>Rule Support</head>

  <p>
<termref def="model_validator">Model validators</termref>
   are <rfc2119>REQUIRED</rfc2119> to support and
  evaluate XPath expressions augmented with the <code>smlfn:deref()</code>
  function in the body of Schematron constraints.</p>

  <p>If the <code>queryBinding</code> attribute is not specified, then its value 
  is assumed to be set to <code>"xslt"</code>. <termref def="model_validator">Model validators</termref>
  <rfc2119>MUST</rfc2119> support the <code>"xslt"</code> query binding. 
  <termref def="model_validator">Model validators</termref> <rfc2119>MAY</rfc2119> additionally support query
  bindings other than <code>"xslt"</code>.</p>
</div2>

<div2 id="Embedded_Rules">
  <head>Rules Associated with Schema Components</head>

<p>SML defines a new property for every complex type definition schema component and every element declaration schema component.
<glist>
<gitem>
<label id="rules">{rules}</label> <def> <p>A set of <termref def="schematron_constraint">Schematron constraints</termref>.</p>
</def>
</gitem>
</glist>
</p>
<div3 id="Rules_Mapping_From_Schema">
<head>SML Rule Construction</head>
<p>
The <termref def="rules">{rules}</termref> property contains all of the Schematron constraints applicable to instances 
of the given type definition or element declaration. Its value is derived in part from 
<code>sch:schema</code> elements embedded within the component, and sometimes in part from the 
<termref def="rules">{rules}</termref> properties of other components. 

</p>
<p>
<code>sch:schema</code> elements <rfc2119>MAY</rfc2119> appear as items in the 
{application information} of the {annotation} of a global element declaration 
or a global complex type definition. This specification assigns no meaning to <code>sch:schema</code>
elements if they appear as items in any other location.
</p>
<p>
Let the <term>local-rules</term> of a given global element declaration or global 
complex type definition 
be the set of Schematron constraints embedded in the {application information} 
of that schema component's {annotation} property. For other schema components,
<term>local-rules</term> is empty.
</p>
<p>The value of the <termref def="rules">{rules}</termref> property of a schema component is computed
 as follows:</p>
<olist>
    <item>
                            <p>
        The value of <termref def="rules">{rules}</termref> for <code>xs:anyType</code> is the empty set.
    </p>
</item>
    <item>

<p>
        If the schema component is a global element declaration, then the
        value of its <termref def="rules">{rules}</termref> is the union of its <term>local-rules</term>
        and the appropriate case from the following:</p>
        <olist>
            <item>

                                    <p>
                If the element declaration has a {substitution group affiliation},
                then the value of <termref def="rules">{rules}</termref> of
                the {substitution group affiliation}.
            </p>
</item>
            <item>
                                    <p>
                Otherwise (the element declaration has no {substitution group affiliation}),
                the empty set.
            </p>
</item>
        </olist>
    </item>
    <item>

<p>
        If the schema component is a complex type definition, then the
        value of its <termref def="rules">{rules}</termref> property is the union of its <term>local-rules</term>
        and the appropriate case from the following:</p>
        <olist>
            <item>

                                    <p>
                If the component's {base type definition} is a complex type definition,
                then the <termref def="rules">{rules}</termref> of the {base type definition}.
                This is true for derivation by extension as well as
                for derivation by restriction.
            </p>
</item>
            <item>
                                    <p>
                Otherwise (i.e., when {base type definition} is a simple type definition),
                the empty set.
            </p>
</item>
        </olist>
    </item>
    <item>
                            <p>Otherwise, the value of the <termref def="rules">{rules}</termref> property is not affected
by this specification.</p>
</item>
</olist>
</div3>

<div3 id="Rules_Schema_Validity_Rules">
<head>Schema Component Rules</head>
<p>
<termref def="model_validator">Model validators</termref>
<rfc2119>MUST</rfc2119> enforce the
following rules.</p>
<olist>
    <item>

                            <p>If a complex type <term>D</term> is derived by restriction
    or extension from {base type definition} <term>B</term> and
    if <term>B</term> has <termref def="rules">{rules}</termref> defined on it then
    they <rfc2119>MUST</rfc2119> be automatically copied to <term>D</term> and unioned with
    the <termref def="rules">{rules}</termref> defined on <term>D</term>.
    </p>
</item>
    <item>

<p>If a complex type <term>D</term> is derived by restriction from
    {base type definition} <term>B</term>, then a global element declaration
    with non-empty <termref def="rules">{rules}</termref> contained in <term>B</term> 
    <rfc2119>MUST NOT</rfc2119> be restricted to a local element declaration in <term>D</term>. </p>
    <note>
<p>It is an error if all of the following are true.</p>
    <olist>
        <item>
                                    <p>An element declaration <term>ED</term> is contained (directly, indirectly, or implicitly)  
        in <term>D</term> and an element declaration <term>EB</term> is
        contained (directly, indirectly, or implicitly) in <term>B</term>.
        </p>
</item>
        <item>
                                    <p>

                                    <term>ED</term> and <term>EB</term>
        satisfy the "NameAndTypeOK" constraint (for XML Schema's definition of
        valid restrictions, see <loc href="http://www.w3.org/TR/xmlschema-1/#cos-particle-restrict" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">Schema Component Constraint: Particle Valid (Restriction)</loc>,
        <loc href="http://www.w3.org/TR/xmlschema-1/#coss-particle" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">Constraints on Particle Schema Components</loc> in [<xspecref href="#XSD1" xlink:type="simple" xlink:show="new" xlink:actuate="onRequest">XML Schema Structures</xspecref>]).
        </p>
</item>
        <item>
                                    <p>
                                    <term>EB</term> is a reference to a global element declaration
        with a Schematron constraint on it.
        </p>
</item>
        <item>
                                    <p>
                                    <term>ED</term> is a local element declaration with the same
        name as <term>EB</term>.
        </p>
</item>
    </olist>
</note>
    </item>
</olist>
</div3>

<div3 id="Rules_Instance_Validity_Rules">
<head>Instance Validity Rules</head>
<p>
<termref def="model_validator">Model validators</termref> 
 <rfc2119>MUST</rfc2119> behave as follows:  </p>
<olist>
  <item>
                            <p>Each <termref def="schematron_constraint">Schematron constraint</termref>
  in <termref def="rules">{rules}</termref> of a complex-type definition
    <b>CT</b> <rfc2119>MUST</rfc2119> be evaluated for all element
    instances of type <b>CT</b> in a model
    during the model's validation.</p>
  </item>
  <item>
                            <p>Each <termref def="schematron_constraint">Schematron constraint</termref>
  in <termref def="rules">{rules}</termref> of a global element
  declaration <b>G</b> <rfc2119>MUST</rfc2119> be evaluated for all
  element instances of <b>G</b> in a model during the model's
  validation.</p>
  </item>
  <item>

<p>All of the assertion tests in fired rules <rfc2119>MUST</rfc2119> succeed.
</p>
  </item>
</olist>
</div3>
</div2>

<div2 id="Rules_in_Rule_Documents">
  <head>Rules Authored in Rule Documents</head>

<div3 id="Rule_Binding">
  <head>Rule Binding</head>

<p>
                        <termref def="model_validator">Model validators</termref> 
 <rfc2119>MUST</rfc2119> provide a
mechanism to support the binding of Schematron patterns, authored in
separate <termref def="ruleDocument">rule documents</termref>, to a
set of documents in a model. Rule documents <rfc2119>MAY</rfc2119> be
bound to model instance documents as well as model definition
documents.  The mechanism for binding rule documents to a set of
documents in a model is implementation-defined.
</p>
</div3>
</div2>

</div1>

<div1 id="Localization_of_Messages">
<head>Localization of Natural Language Messages</head>

<p>
SML defines the <code>sml:locid</code> attribute in support of localization 
of natural-language texts or messages. <termref def="model_validator">Model validators</termref> 
 <rfc2119>MAY</rfc2119> support 
<code>sml:locid</code> attribute on the following elements:
</p>
<olist>
<item>
                    <p>

<code>sch:assert</code> and <code>sch:report</code> 
in a <termref def="ruleDocument">rule document</termref>.</p>
</item>
<item>
                    <p>
<code>sch:assert</code> and <code>sch:report</code> 
in a Schematron <code>pattern</code> embedded in the 
{application information} of the {annotation} property of a 
complex type definition or an element declaration.</p>
</item>
<item>
<p>Elements in instance documents with textual content.</p>
</item>
</olist>
<p>Model validators 
 that support the <code>sml:locid</code>
attribute <rfc2119>MUST</rfc2119> use the <code>sml:locid</code> 
attribute value to access the location of the translated text.
</p>
<note>

<p>The mechanism for using the 
<code>QName</code> value of the <code>sml:locid</code> attribute to locate the 
translated text is implementation dependent. For example, 
the {namespace name} can be used to identify the resource 
containing the text and the {local name} can be used 
to identify the text within such resource. Refer to  
<specref ref="Localization_Sample"/> section for a concrete sample of how 
the <code>sml:locid</code> attribute can be used to support text localization.</p>
</note>

<div2 id="Variable_Substitution">
<head>Variable Substitution </head>

<p>There is often the case that a <code>sch:assert</code>
or <code>sch:report</code> message can be reused in different 
situations. To be able to re-use a message, the schema author 
must be able to substitute variable content based on the 
context in which the message is being used.</p>

<p>
Although this specification does not mandate 
the use of variable substitution in Schematron messages, it suggests the 
use of <code>xsl:variable</code> when variable
substitution is desired.
Refer to <specref ref="Localization_Sample"/> section
for a concrete sample of how the <code>xsl:variable</code>
can be used in support of reusing localized messages.
</p>

</div2>

</div1>

<div1 id="Conformance">
<head>Conformance Criteria</head>


<p>A program is a <emph>conforming SML model processor</emph>
if and only if it satisfies all the constraints
imposed on processors elsewhere in this specification.</p>

<p>A conforming SML model processor is a <emph>conforming SML model 
validator</emph> if and only if it satisfies the following conditions:</p>
<olist>
<item>

                    <p>The validator <rfc2119>MUST</rfc2119> perform <termref def="model_validation_t">model validation</termref>
 as defined in this specification.</p>
</item>
<item>

                    <p>The validator <rfc2119>MUST</rfc2119> support XML 1.0 [<bibref ref="XML10"/>], 
XML Schema 1.0 [<bibref ref="XSD1"/>, <bibref ref="XSD2"/>], and 
XPath 1.0 [<bibref ref="XPath"/>] but <rfc2119>MAY</rfc2119> also additionally support any future versions of these 
specifications.</p>
</item>
<item>
                    <p>The validator MUST support Schematron [<bibref ref="Schematron"/>].</p>
</item>
 <item>
                    <p>The validator <rfc2119>MUST</rfc2119> perform Schematron rule evaluation 
on the #ALL phase.</p>
</item>
<item>
                    <p>The validator <rfc2119>MUST</rfc2119> support the <code>deref()</code> 
XPath extension function.</p>
</item>
<item>

                    <p>The validator <rfc2119>MUST</rfc2119> identify all SML references in the model using 
the Post Schema Validation Infoset. [<bibref ref="XSD1"/>]</p>
</item>
<item>

                    <p>The validator <rfc2119>MUST</rfc2119> use 
the Post Schema Validation Infoset to determine if an 
SML reference in the model is a null SML reference. [<bibref ref="XSD1"/>]</p>

</item>
</olist>

<p>
    The conformance of a model and the validity of a model can be assessed if and
    only if all documents in the model are available to the model validator.  A
    model validator <rfc2119>MUST</rfc2119> document its behavior 
    when a model document is found to be unavailable (i.e. the behavior is implementation-defined).  
    It <rfc2119>MAY</rfc2119> respond to this
    condition in ways that include but are not limited to: assessing the model as
    invalid, or treating this as a warning.  The intent of the latitude granted to
    model validators in this case is to provide some implementation flexibility by
    not prescribing a limited set of choices, however it is be read narrowly
    rather than as a broad license to take unrelated actions like failing to
    enforce SML constraints on unrelated documents.
</p>

<p>A model is a <emph>conforming SML <termref def="model">model</termref>
</emph> if and only if it 
satisfies the following conditions:</p>
<olist>
  <item>
                    <p>Each <termref def="document">document</termref> in the model <rfc2119>MUST</rfc2119> be a
    well-formed XML document [<bibref ref="XML10"/>]</p>
  </item> 
  <item>

                    <p>For each XML Schema document in the model's definition documents, the
[validity] property of the root element <rfc2119>MUST</rfc2119> be "valid" when schema 
validity is assessed with respect to a schema constructed from the  
<bibref ref="XSD3"/> and  <specref ref="SML_schema"/> 
schema documents.</p>
</item>

<item>

<p>All schemas assembled from the XML Schema documents in the model's
definition documents <rfc2119>MUST</rfc2119> satisfy the conditions expressed in Errors in Schema
Construction and Structure (§5.1). [<bibref ref="XSD1"/>]</p>

</item>
<item>

                    <p>
All schemas assembled from the XML Schema documents in the model's
definition documents <rfc2119>MUST</rfc2119> satisfy the conditions expressed in 
sections <specref ref="Acyclic_Mapping_From_Schema"/>, <specref ref="Acyclic_Schema_Validity_Rules"/>, <specref ref="Target_Mapping_From_Schema"/>, <specref ref="Target_Schema_Validity_Rules"/>, <specref ref="Identity_Constraints_Mapping_from_Schema"/>, <specref ref="Identity_Constraints_Schema_Validity_Rules"/>, <specref ref="Rules_Mapping_From_Schema"/> and <specref ref="Rules_Schema_Validity_Rules"/>.
</p>
</item>
  <item>

<p>Each Schematron document in the model's
    definition documents <rfc2119>MUST</rfc2119> be a valid Schematron document [<bibref ref="Schematron"/>]</p>
  </item>
  </olist>
<note>
                <p>This specification does not define how schemas are assembled and
which schema documents contribute to assembling the schemas.</p>
</note>
  
  <p>A <emph>conforming SML model is valid</emph> if and only if it satisfies all of the following
conditions:</p>
<olist>
  <item>

<p>
       In each instance document in the model, which is bound to a schema,
       the [validity] property of the root element <rfc2119>MUST</rfc2119> be "valid",
       and the [validity] property of all the other elements and all the attributes
       <rfc2119>MUST NOT</rfc2119> be "invalid", when schema validity is assessed with respect
       to any schema that is bound to this instance document. The schema validity assessment
       starts with no stipulated declaration or definition at the root element.
       [<bibref ref="XSD1"/>]</p>
       
       <p>The schema-validity of instance documents not bound to any
       schema does not contribute to the validity or invalidity of the 
       model.
       </p>
       <note>
<p>How schemas are bound to instance documents is not defined by this
       specification. Multiple schemas may be bound to the same instance document.</p>
       <p>SML validity entails NOT being Schema-Invalid on the root or any descendant. 
       SML validity can be non-vacuously checked only after assessment of Schema validity,
       and only on the portions of the subtree for which PSVI is available.
       </p>
       <p>
           Because the depth of PSVI is implementation-dependent, there is variability in
           the visibility of SML constraints available to the SML validator, and
           consequently in SML validity results.
       </p>
</note>
  </item>
  <item>
                    <p>Each document in the model <rfc2119>MUST</rfc2119> satisfy all applicable Schematron constraints
   when validated in the #ALL phase.</p>
</item>
  <item>
<p>Each document in the model <rfc2119>MUST</rfc2119> satisfy all normative statements 
  in this specification that pertain to model documents.</p>
  <note>
                        <p>This means, for example, 
  that each document must satisfy all
    applicable sml:acyclic, sml:target*, 
    and SML identity constraints. 
</p>
</note>
  </item>
</olist>

</div1>
<div1 id="SML_Extension_Reference">
<head>SML Extensions Reference (Non-Normative)</head>

<p>This section is a reference guide to the SML extensions of XML
Schema and XPath. </p>

<div2 id="Attributes">
<head>Attributes</head>

<div3 id="sml_acyclic_nonnormative_reference">
<head>sml:acyclic</head>

<p>Used to specify that instances of an SML reference of a given type and its
derived types do not create any cycles in a model </p>
<eg xml:space="preserve">
&lt;xs:attribute name="acyclic" type="xs:boolean"/&gt;
</eg>

<p>If this attribute is set to true for a complex type <b>CT</b>, then instances of <b>CT</b>
(including any derived types of <b>CT</b>) that are SML references cannot create any
cycles in a model. In the following example, HostedOnRefType is a complex type
declaration whose instances cannot create a cycle:</p>

<eg xml:space="preserve">
&lt;xs:complexType name="HostedOnRefType" sml:acyclic="true"&gt;
...
&lt;/xs:complexType&gt;
</eg>

<p>If
the <code>sml:acyclic</code> attribute is not
specified or set to false for a complex type declaration, then instances of this type 
that are SML references may create cycles in a model.
</p>

</div3>
<div3 id="sml_ref_nonnormative_referenc">
<head>sml:ref</head>

<p>This global attribute is used to identify SML references.</p>
<eg xml:space="preserve">
&lt;xs:attribute name="ref" type="xs:boolean"/&gt;
</eg>

<p> Any element that has sml:ref="true" will be treated as an SML reference.
</p>

</div3>
<div3 id="sml_nilref_nonnormative_referenc">
<head>sml:nilref</head>

<p>This global attribute is used to identify null SML references. </p>

<eg xml:space="preserve">
&lt;xs:attribute name="nilref" type="xs:boolean"/&gt;
</eg>

<p>Any SML reference that has <code>sml:nilref="true"</code> or <code>sml:nilref="1"</code> will be treated as a
null SML reference.  
</p>

</div3>

<div3 id="sml_targetElement_nonnormative_referenc">
<head>sml:targetElement</head>

<p>A <code>QName</code> representing the name of a referenced element</p>
<eg xml:space="preserve"> 
&lt;xs:attribute name="targetElement" type="xs:QName"/&gt;
</eg>

<p>
<code>sml:targetElement</code> is supported as an attribute for any element
declaration. The value of this
attribute must be the name of some global element declaration. Let
<code>sml:targetElement="ns:GTE"</code> for some element declaration
<b>E</b>. Then each element instance of <b>E</b> must
target an element that is an instance of <b>ns:GTE</b> or an
instance of some global element declaration in the substitution group
hierarchy whose head is <b>ns:GTE</b>.</p>

<p>In the following example, the element referenced by
instances of <code>HostOS</code> must be an instance
of <code>win:Windows</code>
</p>
<eg xml:space="preserve">
&lt;xs:element name="HostOS" type="tns:HostOSRefType" sml:targetElement="win:Windows" minOccurs="0"/&gt;

&lt;xs:complexType name="HostOSRefType"&gt;
    &lt;xs:sequence&gt;
            &lt;xs:any namespace="##any" processContents="lax" minOccurs="0" maxOccurs="unbounded"/&gt;
    &lt;/xs:sequence&gt;
    &lt;xs:anyAttribute namespace="##any" processContents="lax"/&gt;
&lt;/xs:complexType&gt;
</eg>

<p>A model is invalid if its documents violate
one or more sml:targetElement constraints.</p>

</div3>
<div3 id="sml_targetRequired_nonnormative_referenc">
<head>sml:targetRequired</head>

<p>Used to specify that instances of an SML reference must target elements
in the model; i.e., an instance of the SML reference can not be null
or contain an unresolved reference. Therefore it is an error if <code>targetRequired="true"</code> is specified
on an element declaration where the corresponding 
SML reference element R has <code>sml:nilref="true"</code>.</p>
<eg xml:space="preserve">
&lt;xs:attribute name="targetRequired" type="xs:boolean"/&gt;
</eg>

<p>In the following example, the <code>targetRequired</code> attribute is used
to specify that application instances must have a host operating system.
</p>
<eg xml:space="preserve">
&lt;xs:complexType name="ApplicationType"&gt;
    &lt;xs:sequence&gt;
        &lt;xs:element name="Name" type="xs:string"/&gt;
        &lt;xs:element name="Vendor" type="xs:string"/&gt;
        &lt;xs:element name="Version" type="xs:string"/&gt;
        &lt;xs:element name="HostOSRef" type="tns:HostOSRefType" sml:targetRequired="true"/&gt;
    &lt;/xs:sequence&gt;
&lt;/xs:complexType&gt;

&lt;xs:complexType name="HostOSRefType"&gt;
    &lt;xs:sequence&gt;
      &lt;xs:any namespace="##any" processContents="lax" minOccurs="0" maxOccurs="unbounded"/&gt;
    &lt;/xs:sequence&gt;
    &lt;xs:anyAttribute namespace="##any" processContents="lax"/&gt;
&lt;/xs:complexType&gt;
</eg>

<p>A model is invalid if its documents violate one or more
<code>sml:targetRequired</code> constraints.</p>

</div3>
<div3 id="sml_targetType_nonnormative_referenc">
<head>sml:targetType</head>

<p>A <code>QName</code> representing the type of a referenced element</p>
<eg xml:space="preserve">
&lt;xs:attribute name="targetType" type="xs:QName" /&gt;
</eg>

<p>

<code>sml:targetType</code> is supported as an attribute for any element
declarations. If the value of this
attribute is specified as <code>T</code>, then the
type of the referenced element must either be <code>T</code> or a derived type of <code>T</code>. In
the following example, the type of the element referenced by the
<code>OperatingSystem</code> element must be
"<code>ibm:LinuxType</code>" or its derived
type</p>
<eg xml:space="preserve">
&lt;xs:element name="OperatingSystem" type="tns:OperatingSystemRefType"
            sml:targetType="ibm:LinuxType" minOccurs="0"/&gt;

&lt;xs:complexType name="OperatingSystemRefType"&gt;
    &lt;xs:sequence&gt;
        &lt;xs:any namespace="##any" processContents="lax" minOccurs="0" maxOccurs="unbounded"/&gt;
    &lt;/xs:sequence&gt;
    &lt;xs:anyAttribute namespace="##any" processContents="lax"/&gt;
&lt;/xs:complexType&gt;

</eg>

<p>A model is invalid if its documents violate
one or more sml:targetType constraints.</p>
</div3>

<div3 id="locid_nonnormative_referenc">
<head>sml:locid</head>

<p>This attribute can be defined on the <code>sch:assert</code>,
<code>sch:report</code> and on any element with textual content. 
The <code>sml:locid</code> attribute 
is used to define the translation location for the text 
content of the containing element.
</p>
<eg xml:space="preserve">&lt;xs:attribute name="locid" type="xs:QName"/&gt;</eg>

<p>The mechanism for using the <code>QName</code> value of 
the <code>sml:locid</code> attribute to locate a translated text 
is implementation specific and hence outside the scope of this specification. </p>

</div3>

</div2>
<div2 id="Elements">
<head>Elements</head>

<div3 id="sml_key_nonnormative_referenc">
<head>sml:key</head>

<p>This element is used to specify a key constraint in some scope. The
semantics are the same as that for <code>xs:key</code> except that
<code>sml:key</code> can also be used to specify key constraints on other
documents; i.e., the  <code>sml:selector</code> child element of
<code>sml:key</code> can contain <code>deref</code> functions to resolve
elements in another document.</p>
<eg xml:space="preserve">&lt;xs:element name="key" type="sml:keybase"/&gt;</eg>

<p>

<code>sml:key</code> is supported in the <code>appinfo</code>
of an <code>xs:element</code>.  </p>

</div3>
<div3 id="sml_keyref_nonnormative_referenc">
<head>sml:keyref</head>

<p>Applies a constraint in the context of the containing <code>xs:element</code> that scopes the 
range of a nested document reference.</p>
<eg xml:space="preserve">    
&lt;xs:element name="keyref"&gt;
    &lt;xs:complexType&gt;
        &lt;xs:complexContent&gt;
            &lt;xs:extension base="sml:keybase"&gt;
                &lt;xs:attribute name="refer" type="xs:QName" use="optional"/&gt;
            &lt;/xs:extension&gt;
        &lt;/xs:complexContent&gt;
    &lt;/xs:complexType&gt;
&lt;/xs:element&gt;</eg>

<p>

<code>sml:keyref</code> is supported in the
<code>appinfo</code> of an <code>xs:element</code>.
 </p>

</div3>
<div3 id="sml_unique_nonnormative_referenc">
<head>sml:unique</head>

<p>This element is used to specify a uniqueness constraint in some scope. The
semantics are the same as that for <code>xs:unique</code> except that
<code>sml:unique</code> can also be used to specify uniqueness constraints on
other documents; i.e., the  <code>sml:selector</code> child element of
<code>sml:unique</code> can contain <code>deref</code> functions to resolve
elements in another document.</p>
<eg xml:space="preserve">&lt;xs:element name="unique" type="sml:keybase"/&gt;</eg>

<p>

<code>sml:unique</code> is supported in the
<code>appinfo</code> of an <code>xs:element</code>.
 </p>

</div3>
<div3 id="sml_uri_nonnormative_referenc">
<head>sml:uri</head>

<p>Specifies an SML reference that is an instance of the SML URI reference scheme. </p>
<eg xml:space="preserve">&lt;xs:element name="uri" type="xs:anyURI"/&gt;</eg>

<p>This element must be used to specify SML references that use the
SML URI Reference Scheme.</p>
</div3>
</div2>
<div2 id="XPath_functions">
<head>XPath functions</head>

<div3 id="smlfn_deref_nonnormative_referenc">
<head>smlfn:deref</head>
<eg xml:space="preserve">node-set deref(node-set)</eg>

<p>This function takes a node set and attempts to resolve the
SML references. The resulting node set is the set of
elements that are obtained by successfully resolving (or de-referencing) the
 SML references. For example,</p>
<eg xml:space="preserve">deref(/u:Universities/u:Students/u:Student)</eg>

<p>will resolve the SML reference, <code>Student</code>. The target of an SML reference must
always be an element.</p>
</div3>
</div2>
</div1>
<div1 id="bibl">
  <head>References</head>
    <div2 id="Normative-References">
        <head>Normative</head>

    <blist>
        <bibl key="SML-IF 1.1" id="SML-IF" href="http://www.w3.org/TR/2008/CR-sml-if-20081125/" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">
            <titleref xlink:type="simple" xlink:show="new" xlink:actuate="onRequest">Service Modeling Language Interchange Format Version 1.1</titleref>, Bhalchandra Pandit,
            Valentina Popescu, Virginia Smith, Editors.  World Wide Web Consortium, 25 November 2008. This
            version of the Service Modeling Language Interchange Format specification is available
            at http://www.w3.org/TR/2008/CR-sml-if-20081125/. The
            <loc href="http://www.w3.org/TR/sml-if/" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">latest version of the Service Modeling Language Interchange Format Version 1.1</loc> specification is available at
            http://www.w3.org/TR/sml-if/
        </bibl>
        <bibl key="IETF RFC 2119" href="http://www.ietf.org/rfc/rfc2119.txt" id="RFC2119" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">
        <titleref xlink:type="simple" xlink:show="new" xlink:actuate="onRequest">Key words for use in RFCs to Indicate
        Requirement Levels</titleref>, S. Bradner, Author. Internet
        Engineering Task Force, June 1999. Available at
        http://www.ietf.org/rfc/rfc2119.txt.
      </bibl>
        <bibl key="IETF RFC 3986" href="http://www.ietf.org/rfc/rfc3986.txt" id="RFC3986" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">
        <titleref xlink:type="simple" xlink:show="new" xlink:actuate="onRequest">Uniform Resource Identifier (URI): Generic Syntax
        </titleref>, T. Berners-Lee,  R. Fielding, L. Masinter, Authors. Internet
        Engineering Task Force, January 2005. Available at
        http://www.ietf.org/rfc/rfc3986.txt.
      </bibl>
        <bibl key="IETF RFC 3987" href="http://www.ietf.org/rfc/rfc3987.txt" id="RFC3987" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">
        <titleref xlink:type="simple" xlink:show="new" xlink:actuate="onRequest">Internationalized Resource Identifiers (IRIs)
        </titleref>, M. Duerst,  M. Suignard, Authors. Internet
        Engineering Task Force, January 2005. Available at
        http://www.ietf.org/rfc/rfc3987.txt.
      </bibl>
      <bibl key="RFC 2234" href="http://rfc.net/rfc2234.html" id="RFC2234" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">
        <titleref xlink:type="simple" xlink:show="new" xlink:actuate="onRequest">Augmented BNF for Syntax Specifications: ABNF</titleref>,
        Internet Mail Consortium, November 1997.
        Available at http://rfc.net/rfc2234.html.
      </bibl>
      <bibl key="ISO/IEC 19757-3" id="Schematron" href="http://standards.iso.org/ittf/PubliclyAvailableStandards/c040833_ISO_IEC_19757-3_2006(E).zip" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">
        <titleref xlink:type="simple" xlink:show="new" xlink:actuate="onRequest">Information technology ― Document Schema
        Definition Languages (DSDL) ― Part 3: Rule-based
        validation ― Schematron</titleref>. International
        Organization for Standardization and International
        Electrotechnical Commission, 1 January 2006. Available at
        http://standards.iso.org/ittf/PubliclyAvailableStandards/c040833_ISO_IEC_19757-3_2006(E).zip
      </bibl>
      <bibl id="XML10" key="XML" href="http://www.w3.org/TR/2006/REC-xml-20060816/" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">
        <titleref xlink:type="simple" xlink:show="new" xlink:actuate="onRequest">Extensible Markup Language (XML) 1.0 (Fourth
        Edition)</titleref>, T.  Bray, J. Paoli,
        C. M. Sperberg-McQueen, and E. Maler, Editors. World Wide
        Web Consortium, 10 February 1998, revised 16 August 2006. This version of the XML
        1.0 Recommendation is
        http://www.w3.org/TR/2006/REC-xml-20060816. The <loc href="http://www.w3.org/TR/REC-xml/" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">latest version of XML
        1.0</loc> is available at http://www.w3.org/TR/REC-xml.
      </bibl>
      <bibl id="XMLInfoset" key="XML Information Set" href="http://www.w3.org/TR/2004/REC-xml-infoset-20040204/" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">
        <titleref xlink:type="simple" xlink:show="new" xlink:actuate="onRequest">XML Information Set (Second Edition)</titleref>, 
        John Cowan, Richard Tobin, Editors. World Wide
        Web Consortium, 4 February 2004. This version of the XML
        Information Set Recommendation is
        http://www.w3.org/TR/2004/REC-xml-infoset-20040204/. The <loc href="http://www.w3.org/TR/xml-infoset/" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">latest version of XML
        Information Set</loc> is available at http://www.w3.org/TR/xml-infoset/.
      </bibl>
      <bibl id="XSD1" key="XML Schema Structures" href="http://www.w3.org/TR/2004/REC-xmlschema-1-20041028/" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">
        <titleref xlink:type="simple" xlink:show="new" xlink:actuate="onRequest">XML Schema Part 1: Structures Second
        Edition</titleref>, H. Thompson, D. Beech, M. Maloney, and
        N. Mendelsohn, Editors. World Wide Web Consortium, 2 May
        2001, revised 28 October 2004. This version of the XML
        Schema Part 1 Recommendation is
        http://www.w3.org/TR/2004/REC-xmlschema-1-20041028. The
        <loc href="http://www.w3.org/TR/xmlschema-1/" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">latest
        version of XML Schema 1.0 Part 1</loc> is available at
        http://www.w3.org/TR/xmlschema-1.
      </bibl>

      <bibl key="XML Schema Datatypes" id="XSD2" href="http://www.w3.org/TR/2004/REC-xmlschema-2-20041028/" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">
        <titleref xlink:type="simple" xlink:show="new" xlink:actuate="onRequest">XML Schema Part 2: Datatypes Second
        Edition</titleref>, P. Byron and A. Malhotra,
        Editors. World Wide Web Consortium, 2 May 2001, revised 28
        October 2004. This version of the XML Schema Part 2
        Recommendation is
        http://www.w3.org/TR/2004/REC-xmlschema-2-20041028. The
        <loc href="http://www.w3.org/TR/xmlschema-2/" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">latest
        version of XML Schema 1.0 Part 2</loc> is available at
        http://www.w3.org/TR/xmlschema-2.
      </bibl>
      <bibl key="XML Schema for Schemas" id="XSD3" href="http://www.w3.org/2001/XMLSchema.xsd" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">
        <titleref xlink:type="simple" xlink:show="new" xlink:actuate="onRequest">XML Schema for XML Schemas</titleref>. 
        World Wide Web Consortium, 2 May 2001, revised 28
        October 2004. 
      </bibl>

      <bibl key="XPath" id="XPath" href="http://www.w3.org/TR/1999/REC-xpath-19991116" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">
        <titleref xlink:type="simple" xlink:show="new" xlink:actuate="onRequest">XML Path Language (XPath) Version
        1.0</titleref>, J. Clark and S. DeRose, Editors. World
        Wide Web Consortium, 16 November 1999. This version of XML
        Path Language (XPath) Version 1.0 is
        http://www.w3.org/TR/1999/REC-xpath-19991116. The
        <loc href="http://www.w3.org/TR/xpath" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">latest version of
        XML Path Language (XPath) Version 1.0</loc> is available
        at http://www.w3.org/TR/xpath.
      </bibl>
         <bibl key="XPointer" href="http://www.w3.org/TR/2003/REC-xptr-framework-20030325/" id="XPTR" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">
            <titleref xlink:type="simple" xlink:show="new" xlink:actuate="onRequest">XPointer Framework</titleref>, P. Grosso, E.
            Maler, J. Marsh, and N. Walsh, Editors. World Wide Web
            Consortium, 25 March 2003.  This version of the XPointer
            Framework Recommendation is
            http://www.w3.org/TR/2003/REC-xptr-framework-20030325/ The
            <loc href="http://www.w3.org/TR/xptr-framework/" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">latest
            version of XPointer Framework</loc> is available at
            http://www.w3.org/TR/xptr-framework/.
          </bibl>
         <bibl key="xmlns() Scheme" href="http://www.w3.org/TR/2003/REC-xptr-xmlns-20030325/" id="XPTR-xmlns" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">
            <titleref xlink:type="simple" xlink:show="new" xlink:actuate="onRequest">XPointer xmlns() Scheme</titleref>, S. DeRose,
            R. Daniel Jr., E.  Maler, and J. Marsh, Editors. World
            Wide Web Consortium, 25 March 2003.  This version of the
            XPointer xmlns() Scheme Recommendation is
            http://www.w3.org/TR/2003/REC-xptr-framework-20030325/ The
            <loc href="http://www.w3.org/TR/xptr-xmlns/" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">latest
            version of XPointer xmlns() Scheme</loc> is available at
            http://www.w3.org/TR/xptr-xmlns/.
          </bibl>
    </blist>

    </div2>

    <div2 id="NonNormative-References">
        <head>Non-Normative</head>

    <blist>
      <bibl key="Introduction to Schematron" id="intro_schematron" href="http://www.xml.com/pub/a/2003/11/12/schematron.html" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">
        <titleref xlink:type="simple" xlink:show="new" xlink:actuate="onRequest">An Introduction to Schematron</titleref>, Eddie
        Robertsson, Author.  O'Reilly Media, Inc., 12 November
        2003. Available at
        http://www.xml.com/pub/a/2003/11/12/schematron.html
      </bibl>
      <bibl key="Improving Validation with         Schematron" id="improving_schematron" href="http://msdn2.microsoft.com/en-us/library/aa468554.aspx" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">
        <titleref xlink:type="simple" xlink:show="new" xlink:actuate="onRequest">Improving XML Document Validation with
        Schematron</titleref>, Dare Obasanjo, Author. Microsoft
        Corporation, September 2004. Available at
        http://msdn2.microsoft.com/en-us/library/Aa468554.aspx
      </bibl>
      <bibl id="XSD0" key="XML Schema Primer" href="http://www.w3.org/TR/2004/REC-xmlschema-0-20041028/" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">
        <titleref xlink:type="simple" xlink:show="new" xlink:actuate="onRequest">XML Schema Part 0: Primer Second
        Edition</titleref>, D. Fallside and P. Walmsley,
        Editors. World Wide Web Consortium, 2 May 2001, revised 28
        October 2004. This version of the XML Schema Part 0
        Recommendation is
        http://www.w3.org/TR/2004/REC-xmlschema-0-20041028. The
        <loc href="http://www.w3.org/TR/xmlschema-0/" xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest">latest
        version of XML Schema Part 0</loc> is available at
        http://www.w3.org/TR/xmlschema-0.
      </bibl>
    </blist>
    </div2>
  </div1>
</body>
<back>
<div1 id="SML_schema">
    <head>Normative SML Schema</head>
<eg xml:space="preserve">&lt;?xml version="1.0" encoding="utf-8"?&gt;&#13;
&#13;
&lt;!--&#13;
/*&#13;
 * Copyright © ns World Wide Web Consortium,&#13;
 *&#13;
 * (Massachusetts Institute of Technology, European Research Consortium for&#13;
 * Informatics and Mathematics, Keio University). All Rights Reserved. This&#13;
 * work is distributed under the W3C® Document License [1] in the hope that&#13;
 * it will be useful, but WITHOUT ANY WARRANTY; without even the implied&#13;
 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.&#13;
 *&#13;
 * [1] http://www.w3.org/Consortium/Legal/2002/copyright-documents-20021231&#13;
 */&#13;
--&gt;&#13;
&lt;xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:sml="http://www.w3.org/ns/sml" targetNamespace="http://www.w3.org/ns/sml" elementFormDefault="qualified" blockDefault="#all" version="1.0" xml:lang="en" finalDefault="" attributeFormDefault="unqualified"&gt;&#13;
    &#13;
   &lt;!--&#13;
        References&#13;
        ==========&#13;
    --&gt;&#13;
   &#13;
    &#13;
   &lt;!-- CONTEXT: To be used in any &lt;xs:element&gt; --&gt;&#13;
   &#13;
    &lt;xs:attribute name="ref" type="xs:boolean"&gt;&#13;
        &lt;xs:annotation&gt;&#13;
            &lt;xs:documentation&gt;&#13;
                Specifies if the element contains a reference&#13;
            &lt;/xs:documentation&gt;&#13;
        &lt;/xs:annotation&gt;&#13;
    &lt;/xs:attribute&gt;&#13;
    &#13;
   &lt;!-- CONTEXT: To be used in any &lt;xs:element&gt; --&gt;&#13;
   &#13;
    &lt;xs:attribute name="nilref" type="xs:boolean"&gt;&#13;
        &lt;xs:annotation&gt;&#13;
            &lt;xs:documentation&gt;&#13;
                Specifies that the reference element denotes a “null” reference. &#13;
                To be used only on elements for which sml:ref="true".&#13;
            &lt;/xs:documentation&gt;&#13;
        &lt;/xs:annotation&gt;&#13;
    &lt;/xs:attribute&gt;  &#13;
    &#13;
   &lt;!-- CONTEXT: To be used in any &lt;xs:element&gt; --&gt;&#13;
   &#13;
    &lt;xs:attribute name="targetElement" type="xs:QName"&gt;&#13;
        &lt;xs:annotation&gt;&#13;
            &lt;xs:documentation&gt;&#13;
                A qualified name of a global element in the referenced document.&#13;
            &lt;/xs:documentation&gt;&#13;
        &lt;/xs:annotation&gt;&#13;
    &lt;/xs:attribute&gt;&#13;
    &#13;
   &lt;!-- CONTEXT: To be used in any &lt;xs:element&gt;--&gt;&#13;
   &#13;
    &lt;xs:attribute name="targetRequired" type="xs:boolean"&gt;&#13;
        &lt;xs:annotation&gt;&#13;
            &lt;xs:documentation&gt;&#13;
                If true, requires the target element of the reference to&#13;
                exist in the model.&#13;
            &lt;/xs:documentation&gt;&#13;
        &lt;/xs:annotation&gt;&#13;
    &lt;/xs:attribute&gt;&#13;
    &#13;
   &lt;!-- CONTEXT: To be used in any &lt;xs:element&gt;--&gt;&#13;
   &#13;
    &lt;xs:attribute name="targetType" type="xs:QName"&gt;&#13;
        &lt;xs:annotation&gt;&#13;
            &lt;xs:documentation&gt;&#13;
                A qualified name of the type of the element in the&#13;
                referenced document.&#13;
            &lt;/xs:documentation&gt;&#13;
        &lt;/xs:annotation&gt;&#13;
    &lt;/xs:attribute&gt;&#13;
    &#13;
   &lt;!-- CONTEXT: To be used in any &lt;xs:complexType&gt;--&gt;&#13;
   &#13;
    &lt;xs:attribute name="acyclic" type="xs:boolean"&gt;&#13;
        &lt;xs:annotation&gt;&#13;
            &lt;xs:documentation&gt;&#13;
                If this attribute is set to true for a type D &#13;
                then instances of D should not create any&#13;
                cycles in a model. More precisely, the directed graph whose&#13;
                edges represent instances of D, and whose nodes represent&#13;
                documents that contain the source or target elements for&#13;
                instances of D, must be acyclic.&#13;
            &lt;/xs:documentation&gt;&#13;
        &lt;/xs:annotation&gt;&#13;
    &lt;/xs:attribute&gt;&#13;
    &#13;
    &#13;
   &lt;!-- CONTEXT: To be used in &lt;sch:assert&gt;, &lt;sch:report&gt;&#13;
         and elements with textual content.&#13;
         This attribute is used to support string localization.&#13;
         It is used to define the translation location for &#13;
         the text content of the containing element.--&gt;&#13;
     &#13;
    &lt;xs:attribute name="locid" type="xs:QName"/&gt;&#13;
    &#13;
    &#13;
   &lt;!-- CONTEXT: Represents a reference using the URI scheme. To be&#13;
         used as a child  element of elements for which&#13;
         sml:ref="true". --&gt;&#13;
   &#13;
    &lt;xs:element name="uri" type="xs:anyURI"&gt;&#13;
        &lt;xs:annotation&gt;&#13;
            &lt;xs:documentation&gt;&#13;
                References in URI scheme must be representend by this&#13;
                element.  &#13;
            &lt;/xs:documentation&gt;&#13;
        &lt;/xs:annotation&gt;&#13;
    &lt;/xs:element&gt;&#13;
&#13;
    &#13;
   &lt;!--&#13;
        Uniqueness and Key constraints&#13;
        ==============================&#13;
    --&gt;&#13;
   &#13;
&#13;
    &lt;xs:complexType name="keybase" mixed="false"&gt;&#13;
        &lt;xs:sequence minOccurs="0"&gt;&#13;
            &lt;xs:element name="selector" type="sml:selectorXPathType"/&gt;&#13;
            &lt;xs:element name="field" type="sml:fieldXPathType" maxOccurs="unbounded"/&gt;&#13;
            &lt;xs:any namespace="##other" minOccurs="0" maxOccurs="unbounded" processContents="lax"/&gt;&#13;
        &lt;/xs:sequence&gt;&#13;
        &lt;xs:attribute name="name" type="xs:NCName"/&gt;&#13;
        &lt;xs:attribute name="ref" type="xs:QName"/&gt;&#13;
        &lt;xs:anyAttribute namespace="##other" processContents="lax"/&gt;&#13;
    &lt;/xs:complexType&gt;&#13;
    &lt;xs:element name="key" type="sml:keybase"/&gt;&#13;
    &lt;xs:element name="unique" type="sml:keybase"/&gt;&#13;
    &lt;xs:element name="keyref"&gt;&#13;
        &lt;xs:complexType mixed="false"&gt;&#13;
            &lt;xs:complexContent&gt;&#13;
                &lt;xs:extension base="sml:keybase"&gt;&#13;
                    &lt;xs:attribute name="refer" type="xs:QName" use="optional"/&gt;&#13;
                &lt;/xs:extension&gt;&#13;
            &lt;/xs:complexContent&gt;&#13;
        &lt;/xs:complexType&gt;&#13;
    &lt;/xs:element&gt;&#13;
&#13;
    &#13;
   &lt;!--&#13;
        Other Complex Types&#13;
        ==================&#13;
    --&gt;&#13;
   &#13;
&#13;
    &lt;xs:complexType name="selectorXPathType" mixed="false"&gt;&#13;
        &lt;xs:sequence&gt;&#13;
            &lt;xs:any namespace="##other" minOccurs="0" maxOccurs="unbounded" processContents="lax"/&gt;&#13;
        &lt;/xs:sequence&gt;&#13;
        &lt;xs:attribute name="xpath" use="required"&gt;&#13;
            &lt;xs:simpleType&gt;&#13;
                &lt;xs:restriction base="xs:string"&gt;&#13;
                    &#13;
   &lt;!-- The value MUST conform to the selector BNF grammar defined in&#13;
                         section '4.4 Identity Constraints' in the SML specification.&#13;
                    --&gt;&#13;
   &#13;
                &lt;/xs:restriction&gt;&#13;
            &lt;/xs:simpleType&gt;&#13;
        &lt;/xs:attribute&gt;&#13;
        &lt;xs:anyAttribute namespace="##other" processContents="lax"/&gt;&#13;
    &lt;/xs:complexType&gt;&#13;
&#13;
    &lt;xs:complexType name="fieldXPathType" mixed="false"&gt;&#13;
        &lt;xs:sequence&gt;&#13;
            &lt;xs:any namespace="##other" minOccurs="0" maxOccurs="unbounded" processContents="lax"/&gt;&#13;
        &lt;/xs:sequence&gt;&#13;
        &lt;xs:attribute name="xpath" use="required"&gt;&#13;
            &lt;xs:simpleType&gt;&#13;
                &lt;xs:restriction base="xs:string"&gt;&#13;
                    &#13;
   &lt;!-- The value MUST conform to the field BNF grammar defined in&#13;
                         section '4.4 Identity Constraints' in the SML specification.&#13;
                    --&gt;&#13;
   &#13;
                &lt;/xs:restriction&gt;&#13;
            &lt;/xs:simpleType&gt;&#13;
        &lt;/xs:attribute&gt;&#13;
        &lt;xs:anyAttribute namespace="##other" processContents="lax"/&gt;&#13;
    &lt;/xs:complexType&gt;&#13;
&lt;/xs:schema&gt;&#13;
</eg>
</div1>
<inform-div1 id="Model_Definition_Document_Sample">
    <head>Model Definition Document Sample</head>

<p>This <termref def="model_definition">model definition document</termref> sample illustrates the use of the following SML extensions:</p>
<olist>
  <item>
                    <p>
                        <termref def="reference">SML references</termref>
</p>
  </item>
  <item>
                    <p>
<code>key</code> and <code>keyref</code> constraints</p>
  </item>
  <item>
<p>Schematron constraints</p>
  </item>
</olist>
<eg xml:space="preserve">&lt;?xml version="1.0" encoding="utf-8"?&gt;&#13;
&#13;
&lt;!--&#13;
/*&#13;
 * Copyright ©  World Wide Web Consortium,&#13;
 *&#13;
 * (Massachusetts Institute of Technology, European Research Consortium for&#13;
 * Informatics and Mathematics, Keio University). All Rights Reserved. This&#13;
 * work is distributed under the W3C® Document License [1] in the hope that&#13;
 * it will be useful, but WITHOUT ANY WARRANTY; without even the implied&#13;
 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.&#13;
 *&#13;
 * [1] http://www.w3.org/Consortium/Legal/2002/copyright-documents-20021231&#13;
 */&#13;
--&gt;&#13;
&lt;xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://example.org/SampleModel" xmlns:sml="http://www.w3.org/ns/sml" xmlns:smlfn="http://www.w3.org/ns/sml-function" xmlns:sch="http://purl.oclc.org/dsdl/schematron" targetNamespace="http://example.org/SampleModel" elementFormDefault="qualified" finalDefault="" blockDefault="" attributeFormDefault="unqualified"&gt;&#13;
&#13;
  &lt;xs:simpleType name="SecurityLevel"&gt;&#13;
    &lt;xs:restriction base="xs:string"&gt;&#13;
      &lt;xs:enumeration value="Low"/&gt;&#13;
      &lt;xs:enumeration value="Medium"/&gt;&#13;
      &lt;xs:enumeration value="High"/&gt;&#13;
    &lt;/xs:restriction&gt;&#13;
  &lt;/xs:simpleType&gt;&#13;
&#13;
  &lt;xs:complexType name="Hostref" sml:acyclic="true" mixed="false"&gt;&#13;
    &lt;xs:sequence&gt;&#13;
      &lt;xs:any namespace="##any" processContents="lax" minOccurs="0" maxOccurs="unbounded"/&gt;&#13;
    &lt;/xs:sequence&gt;&#13;
    &lt;xs:anyAttribute namespace="##any" processContents="lax"/&gt;&#13;
  &lt;/xs:complexType&gt;&#13;
&#13;
  &#13;
   &lt;!-- This element represents the host operating system for&#13;
       an application. Note that the type of the referenced&#13;
       element must be OperatingSystemType or a derived type&#13;
       of OperatingSystemType --&gt;&#13;
   &#13;
  &lt;xs:element name="HostOSRef" type="tns:Hostref" sml:targetType="tns:OperatingSystemType"/&gt;&#13;
&#13;
  &lt;xs:complexType name="ApplicationType" mixed="false"&gt;&#13;
    &lt;xs:sequence&gt;&#13;
      &lt;xs:element name="Name" type="xs:string"/&gt;&#13;
      &lt;xs:element name="Vendor" type="xs:string"/&gt;&#13;
      &lt;xs:element name="Version" type="xs:string"/&gt;&#13;
      &lt;xs:element ref="tns:HostOSRef" minOccurs="0"/&gt;&#13;
    &lt;/xs:sequence&gt;&#13;
  &lt;/xs:complexType&gt; &#13;
&#13;
  &lt;xs:simpleType name="ProtocolType"&gt;&#13;
    &lt;xs:list&gt;&#13;
      &lt;xs:simpleType&gt;&#13;
	&lt;xs:restriction base="xs:string"&gt;&#13;
	  &lt;xs:enumeration value="TCP"/&gt;&#13;
	  &lt;xs:enumeration value="UDP"/&gt;&#13;
	  &lt;xs:enumeration value="SMTP"/&gt;&#13;
	  &lt;xs:enumeration value="SNMP"/&gt;&#13;
	&lt;/xs:restriction&gt;&#13;
      &lt;/xs:simpleType&gt;&#13;
    &lt;/xs:list&gt;&#13;
  &lt;/xs:simpleType&gt;&#13;
&#13;
  &lt;xs:complexType name="GuestAppRefType" sml:acyclic="false" mixed="false"&gt;&#13;
    &lt;xs:sequence&gt;&#13;
      &lt;xs:any namespace="##any" processContents="lax" minOccurs="0" maxOccurs="unbounded"/&gt;&#13;
    &lt;/xs:sequence&gt;&#13;
    &lt;xs:anyAttribute namespace="##any" processContents="lax"/&gt;&#13;
  &lt;/xs:complexType&gt;&#13;
  &#13;
  &lt;xs:element name="GuestAppRef" type="tns:GuestAppRefType" sml:targetType="tns:ApplicationType"/&gt;&#13;
&#13;
  &lt;xs:complexType name="OperatingSystemType" mixed="false"&gt;&#13;
    &lt;xs:sequence&gt;&#13;
      &lt;xs:element name="Name" type="xs:string"/&gt;&#13;
      &lt;xs:element name="FirewallEnabled" type="xs:boolean"/&gt;&#13;
      &lt;xs:element name="Protocol" type="tns:ProtocolType"/&gt;&#13;
      &#13;
   &lt;!-- The following element represents the applications hosted by&#13;
	   operating system --&gt;&#13;
   &#13;
      &lt;xs:element name="Applications" minOccurs="0"&gt;&#13;
	&lt;xs:complexType mixed="false"&gt;&#13;
	  &lt;xs:sequence&gt;&#13;
	    &lt;xs:element ref="tns:GuestAppRef" maxOccurs="unbounded"/&gt;&#13;
	  &lt;/xs:sequence&gt;&#13;
	&lt;/xs:complexType&gt;&#13;
      &lt;/xs:element&gt;&#13;
    &lt;/xs:sequence&gt;&#13;
  &lt;/xs:complexType&gt;&#13;
&#13;
  &lt;xs:complexType name="OSRefType" sml:acyclic="false" mixed="false"&gt;&#13;
    &lt;xs:sequence&gt;&#13;
      &lt;xs:any namespace="##any" processContents="lax" minOccurs="0" maxOccurs="unbounded"/&gt;&#13;
    &lt;/xs:sequence&gt;&#13;
    &lt;xs:anyAttribute namespace="##any" processContents="lax"/&gt;&#13;
  &lt;/xs:complexType&gt;&#13;
&#13;
  &lt;xs:element name="OSRef" type="tns:OSRefType" sml:targetType="tns:OperatingSystemType"/&gt;&#13;
&#13;
  &lt;xs:complexType name="WorkstationType" mixed="false"&gt;&#13;
    &lt;xs:sequence&gt;&#13;
      &lt;xs:element name="Name" type="xs:string"/&gt;&#13;
      &lt;xs:element ref="tns:OSRef"/&gt;&#13;
      &lt;xs:element name="Applications" minOccurs="0"&gt;&#13;
	&lt;xs:complexType mixed="false"&gt;&#13;
	  &lt;xs:sequence&gt;&#13;
	    &lt;xs:element ref="tns:GuestAppRef" maxOccurs="unbounded"/&gt;&#13;
	  &lt;/xs:sequence&gt;&#13;
	&lt;/xs:complexType&gt;&#13;
      &lt;/xs:element&gt;&#13;
    &lt;/xs:sequence&gt;&#13;
  &lt;/xs:complexType&gt; &#13;
&#13;
  &lt;xs:element name="Workstation" type="tns:WorkstationType"&gt;&#13;
    &lt;xs:annotation&gt;&#13;
      &lt;xs:appinfo&gt;&#13;
	&lt;sch:schema&gt;&#13;
	  &lt;sch:ns prefix="sm" uri="SampleModel"/&gt;&#13;
	  &lt;sch:ns prefix="smlfn" uri="http://www.w3.org/ns/sml-function"/&gt;&#13;
	  &lt;sch:pattern id="OneHostOS"&gt;&#13;
	    &#13;
   &lt;!-- The constraints in the following rule are evaluated  &#13;
		 For all instances of the Workstation global element--&gt;&#13;
   &#13;
	    &lt;sch:rule context="."&gt;&#13;
	      &#13;
   &lt;!-- define a named variable - MyApplications -&#13;
		   for use in test expression--&gt;&#13;
   &#13;
	      &lt;sch:let name="MyApplications" value="smlfn:deref(sm:Applications/sm:GuestAppRef)"/&gt;&#13;
	      &lt;sch:assert test="count($MyApplications)=count($MyApplications/sm:HostOSRef)"&gt;&#13;
		Each application in workstation&#13;
		&lt;sch:value-of select="string(sm:Name)"/&gt;&#13;
		must be hosted on an operating system&#13;
	      &lt;/sch:assert&gt;&#13;
	    &lt;/sch:rule&gt;&#13;
	  &lt;/sch:pattern&gt;&#13;
	&lt;/sch:schema&gt;&#13;
&#13;
	&#13;
   &lt;!-- In a workstation, (Vendor,Name,Version) is the key for&#13;
	     guest applications --&gt;&#13;
   &#13;
	&lt;sml:key name="GuestApplicationKey"&gt;&#13;
	  &lt;sml:selector xpath="smlfn:deref(tns:Applications/tns:GuestAppRef)"/&gt;&#13;
	  &lt;sml:field xpath="tns:Vendor"/&gt;&#13;
	  &lt;sml:field xpath="tns:Name"/&gt;&#13;
	  &lt;sml:field xpath="tns:Version"/&gt;&#13;
	&lt;/sml:key&gt;&#13;
&#13;
	&#13;
   &lt;!-- In a workstation, Name is the key for operating system --&gt;&#13;
   &#13;
	&lt;sml:key name="OSKey"&gt;&#13;
	  &lt;sml:selector xpath="smlfn:deref(tns:OSRef)"/&gt;&#13;
	  &lt;sml:field xpath="tns:Name"/&gt;&#13;
	&lt;/sml:key&gt;&#13;
	&#13;
	&#13;
   &lt;!-- In a workstation, the applications hosted by the&#13;
	     referenced operatinsystem must be a subset of the&#13;
	     applications in the workstation --&gt;&#13;
   &#13;
	&lt;sml:keyref name="OSGuestApplication" refer="tns:GuestApplicationKey"&gt;&#13;
	  &lt;sml:selector xpath="smlfn:deref(tns:OSRef)/tns:Applications/tns:GuestAppRef"/&gt;&#13;
	  &lt;sml:field xpath="tns:Vendor"/&gt;&#13;
	  &lt;sml:field xpath="tns:Name"/&gt;&#13;
	  &lt;sml:field xpath="tns:Version"/&gt;   &#13;
	&lt;/sml:keyref&gt;&#13;
&#13;
	&#13;
   &lt;!-- In a workstation, the host operating system of guest&#13;
	     applications must be a subset of the operating system in&#13;
	     the workstation --&gt;&#13;
   &#13;
	&lt;sml:keyref name="ApplicationHostOS" refer="tns:OSKey"&gt;&#13;
	  &lt;sml:selector xpath="smlfn:deref(tns:Applications/tns:GuestAppRef)/tns:HostOSRef"/&gt;&#13;
	  &lt;sml:field xpath="tns:Name"/&gt;&#13;
	&lt;/sml:keyref&gt;&#13;
      &lt;/xs:appinfo&gt;&#13;
    &lt;/xs:annotation&gt;&#13;
  &lt;/xs:element&gt;&#13;
&#13;
  &lt;xs:element name="SecureWorkstation" type="tns:WorkstationType"&gt;&#13;
    &lt;xs:annotation&gt;&#13;
      &lt;xs:appinfo&gt;&#13;
	&lt;sch:schema&gt;&#13;
	  &lt;sch:ns prefix="sm" uri="SampleModel"/&gt;&#13;
	  &lt;sch:ns prefix="smlfn" uri="http://www.w3.org/ns/sml-function"/&gt;&#13;
	  &lt;sch:pattern id="SecureApplication"&gt;&#13;
	    &lt;sch:rule context="sm:Applications/sm:Application"&gt;&#13;
	      &lt;sch:report test="smlfn:deref(.)[sm:SecurityLevel!='High']"&gt;&#13;
		Application &lt;sch:value-of select="string(sm:Name)"/&gt;&#13;
		from &lt;sch:value-of select="string(sm:Vendor)"/&gt;&#13;
		does not have high security level.&#13;
	      &lt;/sch:report&gt;&#13;
	      &lt;sch:assert test="smlfn:deref(.)[sm:Vendor='TrustedVendor']"&gt;&#13;
		A secure workstation can only contain&#13;
		applications from TrustedVendor.&#13;
	      &lt;/sch:assert&gt;&#13;
	    &lt;/sch:rule&gt;&#13;
	  &lt;/sch:pattern&gt;&#13;
	&lt;/sch:schema&gt;&#13;
      &lt;/xs:appinfo&gt;&#13;
    &lt;/xs:annotation&gt;&#13;
  &lt;/xs:element&gt;&#13;
&#13;
&lt;/xs:schema&gt;&#13;
</eg>
</inform-div1>

<inform-div1 id="SML_References_Sample">
<head>SML References Sample</head>
<p>The following example illustrates the use of SML references.
Consider the following schema fragment:</p>

<eg xml:space="preserve">
&lt;xs:element name="EnrolledCourse"&gt;
    &lt;xs:complexType&gt;
        &lt;xs:sequence&gt;
          &lt;xs:element name="Name" type="xs:string"/&gt;
          &lt;xs:element name="Grade" type="xs:string"/&gt;
          &lt;xs:any namespace="##any" minOccurs="0"
                  maxOccurs="unbounded" processContents="lax"/&gt;
        &lt;/xs:sequence&gt;
        &lt;xs:anyAttribute namespace="##any" processContents="lax"/&gt;
    &lt;/xs:complexType&gt;
&lt;/xs:element&gt;

&lt;xs:complexType name="StudentType"&gt;
    &lt;xs:sequence&gt;
        &lt;xs:element name="ID" type="xs:string"/&gt;
        &lt;xs:element name="Name" type="xs:string"/&gt;
        &lt;xs:element name="EnrolledCourses" minOccurs="0"&gt;
            &lt;xs:complexType&gt;
                &lt;xs:sequence&gt;
                    &lt;xs:element ref="tns:EnrolledCourse" maxOccurs="unbounded"/&gt;
                &lt;/xs:sequence&gt;
            &lt;/xs:complexType&gt;
        &lt;/xs:element&gt;
    &lt;/xs:sequence&gt;
&lt;/xs:complexType&gt;</eg>

<p>The schema definition in the above example is
SML agnostic and does not make use of any SML attributes, elements, or types.
The <code>EnrolledCourse</code> element,
however, has an open content model and this can be used to mark instances
of <code>EnrolledCourse</code> as
SML references as shown below:</p>

<eg xml:space="preserve">
&lt;Student xmlns="http://www.university.example.org/ns"
         xmlns:sml="http://www.w3.org/ns/sml"
         xmlns:u="http://www.university.example.org/ns"&gt;
    &lt;ID&gt;1000&lt;/ID&gt;
    &lt;Name&gt;John Doe&lt;/Name&gt;
    &lt;EnrolledCourses&gt;
        &lt;EnrolledCourse sml:ref="true"&gt;
            &lt;Name&gt;PHY101&lt;/Name&gt;
            &lt;Grade&gt;A&lt;/Grade&gt;
            &lt;sml:uri&gt;
                http://www.university.example.org/Universities/MIT/Courses.xml
                #smlxpath1(/u:Courses/u:Course[u:Name='PHY101'])
            &lt;/sml:uri&gt;
        &lt;/EnrolledCourse&gt;
        &lt;EnrolledCourse sml:ref="false"&gt;
            &lt;Name&gt;MAT100&lt;/Name&gt;
            &lt;Grade&gt;B&lt;/Grade&gt;
            &lt;sml:uri&gt;
                http://www.university.example.org/Universities/MIT/Courses.xml
                #smlxpath1(/u:Courses/u:Course[u:Name='MAT100'])
            &lt;/sml:uri&gt;
        &lt;/EnrolledCourse&gt;
        &lt;EnrolledCourse&gt;
            &lt;Name&gt;SocialSkills&lt;/Name&gt;
            &lt;Grade&gt;F&lt;/Grade&gt;
        &lt;/EnrolledCourse&gt;
    &lt;/EnrolledCourses&gt;
&lt;/Student&gt;
</eg>

<p>The first <code>EnrolledCourse</code> element in the above example
is an SML reference since it specifies
<code>sml:ref="true"</code>. It uses the SML URI Reference Scheme to target
 the element for course  PHY101. The second and third
<code>EnrolledCourse</code> elements are not SML references; the
second element specifies <code>sml:ref="false"</code> and
the third element does not specify the <code>sml:ref</code>
attribute. Note that the second <code>EnrolledCourse</code> element 
contains an <code>sml:uri</code> element which satisfies the syntax of the
SML URI Reference Scheme (referring to course MAT100) 
but this will be ignored since <code>sml:ref="false"</code> 
for this <code>EnrolledCourse</code> element. </p>

<p>Note that, there are no SML constraints defined on the <code>EnrolledCourse</code> element or 
on the type of that element in the schema. Therefore, even if the first <code>EnrolledCourse</code> element instance is marked as an SML reference, no SML constraints are evaluated for that element 
during model validation. However, checks such as the ones defined in section <specref ref="At_Most_One_Target"/> and section <specref ref="Consistent_References"/> are still performed on that SML reference during model validation. </p>

<p>An <code>EnrolledCourse</code> 
SML reference can be a marked as a null reference if it specifies the <code>sml:nilref="true"</code> 
attribute as shown in the following example (the first <code>EnrolledCourse</code> 
element is a null SML reference):</p>

<eg xml:space="preserve">
&lt;Student xmlns="http://www.university.example.org/ns"
         xmlns:sml="http://www.w3.org/ns/sml"
         xmlns:u="http://www.university.example.org/ns"&gt;
    &lt;ID&gt;1000&lt;/ID&gt;
    &lt;Name&gt;John Doe&lt;/Name&gt;
    &lt;EnrolledCourses&gt;
        &lt;EnrolledCourse sml:ref="true" sml:nilref="true"&gt;
            &lt;Name&gt;PHY101&lt;/Name&gt;
            &lt;Grade&gt;A&lt;/Grade&gt;
        &lt;/EnrolledCourse&gt;
        &lt;EnrolledCourse sml:ref="false"&gt;
            &lt;Name&gt;MAT100&lt;/Name&gt;
            &lt;Grade&gt;B&lt;/Grade&gt;
            &lt;sml:uri&gt;
                http://www.university.example.org/Universities/MIT/Courses.xml
                #smlxpath1(/u:Courses/u:Course[u:Name='MAT100'])
            &lt;/sml:uri&gt;
        &lt;/EnrolledCourse&gt;
        &lt;EnrolledCourse&gt;
            &lt;Name&gt;SocialSkills&lt;/Name&gt;
            &lt;Grade&gt;F&lt;/Grade&gt;
        &lt;/EnrolledCourse&gt;
    &lt;/EnrolledCourses&gt;
&lt;/Student&gt;
</eg>

<p>
In the above example, the first SML reference, <code>EnrolledCourse</code>, defines 
the <code>sml:nilref="true"</code> attribute which marks this as a null SML reference.
By specifying a null reference, the document author makes an explicit declaration
that this <code>Student</code> element does not refer to any target element.
Specifying a null reference does not have any SML-defined effect on the interpretation of element
in non-SML contexts.  In particular, in this case, SML says nothing about the
interpretation of the <code>Grade</code> and <code>Name</code> elements.
Any such interpretation is left to the application, its usage context, other specifications, etc.
</p>
</inform-div1>

<inform-div1 id="SML_URI_Reference_Scheme_Example">
<head>SML URI Reference Scheme Sample</head>

<p>The following example illustrates the use of the SML URI Reference Scheme [<specref ref="URI_Reference_Scheme"/>].
Consider the case where all courses offered by MIT are stored in a
single XML document – <code>Courses.xml</code> –
whose URI is  <code>http://www.university.example.org/Universities/MIT/Courses.xml</code>. In this case, the element inside
<code>Courses.xml</code> that corresponds to the course
PHY101 can be referenced as follows (assuming that <code>Courses</code>is the root element in
<code>Courses.xml</code>)</p>
<eg xml:space="preserve">
&lt;Student xmlns="http://www.university.example.org/ns"&gt;
    &lt;ID&gt;1000&lt;/ID&gt;
    &lt;Name&gt;John Doe&lt;/Name&gt;
    &lt;EnrolledCourses&gt;
        &lt;EnrolledCourse sml:ref="true" xmlns:u="http://www.university.example.org/ns"&gt;
            &lt;sml:uri&gt;
                http://www.university.example.org/Universities/MIT/Courses.xml
                #smlxpath1(/u:Courses/u:Course[u:Name='PHY101'])
            &lt;/sml:uri&gt;
        &lt;/EnrolledCourse&gt;
    &lt;/EnrolledCourses&gt;
&lt;/Student&gt;
</eg>

<p>An SML reference can also 
reference an element in its own document. To see this consider the following
instance document</p>

<eg xml:space="preserve">
&lt;University xmlns="http://www.university.example.org/ns"&gt;
    &lt;Name&gt;MIT&lt;/Name&gt;
    &lt;Courses&gt;
        &lt;Course&gt;
            &lt;Name&gt;PHY101&lt;/Name&gt;
        &lt;/Course&gt;
        &lt;Course&gt;
            &lt;Name&gt;MAT200&lt;/Name&gt;
        &lt;/Course&gt;
    &lt;/Courses&gt;
    &lt;Students&gt;
        &lt;Student&gt;
            &lt;ID&gt;123&lt;/ID&gt;
            &lt;Name&gt;Jane Doe&lt;/Name&gt;
            &lt;EnrolledCourses&gt;
                &lt;EnrolledCourse sml:ref="true" xmlns:u="http://www.university.example.org/ns"&gt;
                    &lt;sml:uri&gt;
                        #smlxpath1(/u:University/u:Courses/u:Course[u:Name='MAT200'])
                    &lt;/sml:uri&gt;
                &lt;/EnrolledCourse&gt;
            &lt;/EnrolledCourses&gt;
        &lt;/Student&gt;
    &lt;/Students&gt;
&lt;/University&gt;
</eg>

<p>Here, the <code>EnrolledCourse</code> element for the student
Jane Doe references the <code>Course</code> element for MAT200 in
the same document.</p>
</inform-div1>

<inform-div1 id="Identity_Constraints_Example">

<head>SML Identity Constraints Sample</head>

<p>The following example will be used to illustrate the <code>sml:key</code>,
<code>sml:unique</code>, and <code>sml:keyref</code> constraints across SML
references. This example consists of three schema documents. <code>university.xsd</code> 
contains the type definitions for a University element, a
Student SML reference and a Course SML reference. 
<code>students.xsd</code> contains the 
type definitions for an EnrolledCourse SML reference and a Student element. 
<code>courses.xsd</code> contains the type definition for a Course element. 
</p>

<eg xml:space="preserve">
&lt;!-- from university.xsd --&gt;
&lt;xs:complexType name="StudentRefType"&gt;
    &lt;!-- SML reference to a Student --&gt;
    &lt;xs:sequence&gt;
        &lt;xs:any namespace="##any" processContents="lax" minOccurs="0" maxOccurs="unbounded"/&gt;
    &lt;/xs:sequence&gt;
    &lt;xs:anyAttribute namespace="##any" processContents="lax"/&gt;
&lt;/xs:complexType&gt;
  
&lt;xs:element name="Student" type="StudentRefType"/&gt;

&lt;xs:complexType name="CourseRefType"&gt;
    &lt;!-- SML reference to a Course --&gt;
    &lt;xs:sequence&gt;
        &lt;xs:any namespace="##any" processContents="lax" minOccurs="0" maxOccurs="unbounded"/&gt;
    &lt;/xs:sequence&gt;
    &lt;xs:anyAttribute namespace="##any" processContents="lax"/&gt;
&lt;/xs:complexType&gt;

&lt;xs:element name="Course" type="CourseRefType"/&gt;

&lt;xs:complexType name="UniversityType"&gt;
    &lt;xs:sequence&gt;
        &lt;xs:element name="Name" type="xs:string"/&gt;
        &lt;xs:element name="Students" minOccurs="0"&gt;
        &lt;xs:complexType&gt;
            &lt;xs:sequence&gt;
              &lt;xs:element ref="Student" maxOccurs="unbounded"/&gt;
            &lt;/xs:sequence&gt;
        &lt;/xs:complexType&gt;
        &lt;/xs:element&gt;
        &lt;xs:element name="Courses" minOccurs="0"&gt;
        &lt;xs:complexType&gt;
            &lt;xs:sequence&gt;
              &lt;xs:element ref="Course" maxOccurs="unbounded"/&gt;
            &lt;/xs:sequence&gt;
        &lt;/xs:complexType&gt;
        &lt;/xs:element&gt;
    &lt;/xs:sequence&gt;
&lt;/xs:complexType&gt;

&lt;!-- from students.xsd --&gt;
&lt;xs:complexType name="EnrolledCourseRefType"&gt;
    &lt;!-- SML reference to a Course --&gt;
    &lt;xs:sequence&gt;
        &lt;xs:element name="Grade" type="xs:string"/&gt;
        &lt;xs:any namespace="##any" processContents="lax" minOccurs="0" maxOccurs="unbounded"/&gt;
    &lt;/xs:sequence&gt;
    &lt;xs:anyAttribute namespace="##any" processContents="lax"/&gt;
&lt;/xs:complexType&gt;

&lt;xs:element name="EnrolledCourse" type="EnrolledCourseRefType"/&gt;

&lt;xs:complexType name="StudentType"&gt;
    &lt;xs:sequence&gt;
        &lt;xs:element name="ID" type="xs:string"/&gt;
        &lt;xs:element name="SSN" type="xs:string" minOccurs="0"/&gt;
        &lt;xs:element name="Name" type="xs:string"/&gt;
        &lt;xs:element name="EnrolledCourses" minOccurs="0"&gt;
        &lt;xs:complexType&gt;
            &lt;xs:sequence&gt;
                &lt;xs:element ref="EnrolledCourse" maxOccurs="unbounded"/&gt;
            &lt;/xs:sequence&gt;
        &lt;/xs:complexType&gt;
        &lt;/xs:element&gt;
    &lt;/xs:sequence&gt;
&lt;/xs:complexType&gt;

&lt;xs:element name="Students"&gt;
    &lt;xs:complexType&gt;
        &lt;xs:sequence&gt;
            &lt;xs:element name="Student" type="StudentType"/&gt;
        &lt;/xs:sequence&gt;
    &lt;/xs:complexType&gt;
&lt;/xs:element&gt;

&lt;!-- from courses.xsd --&gt;
&lt;xs:complexType name="CourseType"&gt;
    &lt;xs:sequence&gt;
        &lt;xs:element name="Name" type="xs:string"/&gt;
        &lt;xs:element name="EnrolledStudents" minOccurs="0"&gt;
        &lt;xs:complexType&gt;
            &lt;xs:sequence&gt;
                &lt;xs:element name="EnrolledStudent" maxOccurs="unbounded"&gt;
                &lt;xs:complexType&gt;
                    &lt;xs:sequence&gt;
                        &lt;xs:element name="StudentID" type="xs:string"/&gt;
                    &lt;/xs:sequence&gt;
                &lt;/xs:complexType&gt;
                &lt;/xs:element&gt;
            &lt;/xs:sequence&gt;
        &lt;/xs:complexType&gt;
        &lt;/xs:element&gt;
    &lt;/xs:sequence&gt;
&lt;/xs:complexType&gt;

&lt;xs:element name="Courses"&gt;
    &lt;xs:complexType&gt;
        &lt;xs:sequence&gt;
            &lt;xs:element name="Course" type="CourseType"/&gt;
        &lt;/xs:sequence&gt;
    &lt;/xs:complexType&gt;
&lt;/xs:element&gt;
</eg>

<p>
                <term>sml:key and sml:unique</term>

</p>

<p>XML Schema supports key and uniqueness constraints through
<code>xs:key</code> and <code>xs:unique,</code> but these constraints can
only be specified within a single XML document. The <code>sml:key</code> and
<code>sml:unique</code> elements  support the specification of key and
uniqueness constraints across documents.  We'll use the <code>UniversityType</code>
definition to illustrate this concept. It is reasonable to expect that each
student in a university must have a unique identity, and this identity must
be specified. This can be expressed as follows:</p>
<eg xml:space="preserve">
&lt;xs:element name="University" type="tns:UniversityType"&gt;
    &lt;xs:annotation&gt;
        &lt;xs:appinfo&gt;
            &lt;sml:key name="StudentIDisKey"&gt;
                &lt;sml:selector xpath="smlfn:deref(tns:Students/tns:Student)/tns:ID"/&gt;
                &lt;sml:field xpath="."/&gt;  
            &lt;/sml:key&gt;  
        &lt;/xs:appinfo&gt;
    &lt;/xs:annotation&gt;
&lt;/xs:element&gt;
</eg>

<p>The <code>sml:key</code> and <code>sml:unique</code> constraints are
similar but not the same. <code>sml:key</code> requires that the specified
fields must be present in instance documents and have unique values, whereas
<code>sml:unique</code> simply requires the specified fields to have unique
values but does not require them to be present in instance documents.  Thus
keys imply uniqueness, but uniqueness does not imply keys.  For example,
students in a university must have a unique social security numbers, but the
university may have foreign students who do not possess this number. This
constraint can be specified as follows:</p>
<eg xml:space="preserve">
&lt;xs:element name="University" type="tns:UniversityType"&gt;
    &lt;xs:annotation&gt;
        &lt;xs:appinfo&gt;
            &lt;sml:unique name="StudentSSNisUnique"&gt;
                &lt;sml:selector xpath="smlfn:deref(tns:Students/tns:Student)"/&gt;
                &lt;sml:field xpath="tns:SSN"/&gt;  
            &lt;/sml:unique&gt;  
        &lt;/xs:appinfo&gt;
    &lt;/xs:annotation&gt;
&lt;/xs:element&gt;
</eg>

<p>The <code>sml:key</code> and <code>sml:unique</code>  constraint
are always specified in the context of a scoping element. In the above
example, the <code>University</code> element declaration is the
context for the key and unique constraints.</p>

<p>The following example illustrates the use of the <code>ref</code>
attribute in an SML identity constraint:</p>
<eg xml:space="preserve">
&lt;xs:element name="PrivateUniversity" type="tns:UniversityType"&gt;
    &lt;xs:annotation&gt;
        &lt;xs:appinfo&gt;
            &lt;sml:unique ref="tns:StudentSSNisUnique"/&gt;
        &lt;/xs:appinfo&gt;
    &lt;/xs:annotation&gt;
&lt;/xs:element&gt;</eg>

<p>In the above example, the <code>PrivateUniversity</code> element
declaration specifies the <code>StudentSSNisUnique</code> unique
constraint by referencing its <code>name</code> in the
<code>University</code> element declaration.</p>

<p>
                <term>sml:keyref</term>

</p>

<p>XML Schema supports key references through <code>xs:keyref</code> to
ensure that one set of values is a subset of another set of values within an
XML document. Such constraints are similar to foreign keys in relational
databases. Key references in XML Schema are only supported within a single
XML document. The <code>sml:keyref</code> element allows key references to be
specified across SML references and across XML documents. The following example uses
<code>sml:keyref</code> to capture the requirement that students enrolled in a course
must be currently enrolled in the university:</p>
<eg xml:space="preserve">
&lt;xs:element name="University" type="tns:UniversityType"&gt;
    &lt;xs:annotation&gt;
        &lt;xs:appinfo&gt;
            &lt;sml:key name="StudentIDisKey"&gt;
                &lt;sml:selector xpath="smlfn:deref(tns:Students/tns:Student)"/&gt;
                &lt;sml:field xpath="tns:ID"/&gt;  
            &lt;/sml:key&gt;  
            &lt;sml:keyref name="CourseStudents" refer="tns:StudentIDisKey"&gt;
                &lt;sml:selector xpath="smlfn:deref(tns:Courses/tns:Course)/tns:EnrolledStudents/tns:EnrolledStudent"/&gt;
                &lt;sml:field xpath="tns:ID"/&gt;
            &lt;/sml:keyref&gt;
        &lt;/xs:appinfo&gt;
    &lt;/xs:annotation&gt;
&lt;/xs:element&gt;</eg>

<p>The above constraint specifies that for a university, the set of IDs of
students enrolled in a course is a subset of the set of IDs of students currently enrolled
in the university. In particular, the <code>selector</code> and <code>field</code>
elements in <code>StudentIDisKey</code> key constraint identify the set of
IDs of students currently enrolled in the university, and the <code>selector</code> and
<code>field</code> elements in <code>CourseStudents</code> key reference
constraint identify the set of IDs of students enrolled in courses.   </p>

</inform-div1>

<inform-div1 id="Localization_Sample">
<head>Localization and Variable Substitution Sample</head>
<p>
In the following example, the <code>sml:locid</code> attribute is used 
to define the translation information for the Schematron 
<code>sch:assert</code> error message:
</p>
<eg xml:space="preserve">
&lt;sch:schema xmlns:sch="http://purl.oclc.org/dsdl/schematron"
            xmlns:lang="http://www.university.example.org/translation/"&gt;
  
    &lt;sch:ns prefix="u" uri="http://www.university.example.org/ns" /&gt;
    &lt;sch:ns prefix="smlfn" uri="http://www.w3.org/ns/sml-function"/&gt;
    &lt;sch:pattern id="StudentPattern”&gt;
        &lt;sch:rule context="u:Students/u:Student"&gt;
            &lt;sch:assert test="smlfn:deref(.)[starts-with(u:ID,'99')]"
                        sml:locid="lang:StudentIDErrorMsg"&gt;
                The specified ID &lt;sch:value-of select="string(u:ID)"/&gt; does not begin with 99.
            &lt;/sch:assert&gt;
        &lt;/sch:rule&gt;
    &lt;/sch:pattern&gt;
&lt;/sch:schema&gt;
</eg>

<p>In this example, the {namespace name} URI information of the 
<code>sml:locid</code> attribute is used to define the location 
for the resource containing the translated text:
</p>
<eg xml:space="preserve">xmlns:lang="http://www.university.example.org/translation/"</eg>

<p>The {namespace name} URI can point to a file containing the translated message, 
a folder containing a set of translated files or any other type of resource 
that can help locate the translated message. It is implementation dependent how the 
model validator makes use of this information for finding the actual resource 
containing the translated message.</p>

<p>
In this example, <code>http://www.university.example.org/translation/</code>
points to a folder containing a set of translation resources. For this specific example,
there will be a set of translation files located under 
<code>http://www.university.example.org/translation/</code>. Each of these translation
files will correspond to a language in which the messages have been translated.
For this example, the translation is only available in French and German so there 
are only two files under  <code>http://www.university.example.org/translation/</code>:
</p>
<olist>
<item>
                    <p>
<code>http://www.university.example.org/translation/fr_lang.txt</code> file contains
the French translation of the <code>sch:assert</code> message.</p>
</item>
<item>
<p>

<code>http://www.university.example.org/translation/de_lang.txt</code> contains
the German translation of the <code>sch:assert</code> message.</p>
</item>
</olist>

<p>The {local part} information of the <code>sml:locid</code> 
attribute is used to define the identity of the message being translated. 
This information will be used to locate the translated text within 
the translation resource.
</p>

<p>The file <code>http://www.university.example.org/translation/fr_lang.txt</code> contains
the French translation of the <code>sch:assert</code> message, identified by  
<code>StudentIDErrorMsg</code>, which is the {local part} information of the <code>sml:locid</code> attribute:</p>
<eg xml:space="preserve">StudentIDErrorMsg = L'identifieur specifie &lt;sch:value-of select="string(u:ID)"/&gt; ne commence pas par 99.</eg>
<p>The file <code>http://www.university.example.org/translation/de_lang.txt</code> contains
the German translation for the <code>sch:assert</code> message. The message is identified by  
<code>StudentIDErrorMsg</code>, which is the {local part} information of the <code>sml:locid</code> attribute:</p>
<eg xml:space="preserve">StudentIDErrorMsg = Das angegebene Attributkennzeichen ID &lt;sch:value-of select="string(u:ID)"/&gt; beginnt nicht mit 99.</eg>
<p>
This example demonstrates how localization can be applied to a Schematron rule with the
purpose of making the Schematron rule available to 
<termref def="model_processor">model processors</termref> using different languages. 
Summarized below are the benefits resulting from using the <code>sml:locid</code> localization support:
</p>
<olist>
<item>

<p>The Schematron rule is language agnostic in the sense that the author does 
not have to be aware of the locale of a potential <termref def="model_processor">model processor</termref>. The Schematron rule 
is defined generically, to be consumed by any producer for
which a translation file is made available at the location defined by the 
<code>sml:locid</code> {namespace name} URI.</p>
</item>
<item>
<p>There is a clear separation between the translation process and the Schematron rule.
There are no changes required to be applied to the Schematron rule when translations 
for other languages are made available. To support a new language,
all that needs to be done is to add a new translation file under the location identified by the
<code>sml:locid</code> {namespace name} URI. 
</p>
</item>
</olist>
<p>
                <term>Variable substitution support</term>

</p>
<p>
There is often the case that a message can be reused in different
<code>sch:assert</code> or <code>sch:report</code> situations. 
In the example above, the author of the Schematron rule may 
want to use this error message in other contexts:
</p>
<eg xml:space="preserve">The specified ID &lt;sch:value-of select="string(u:ID)"/&gt; does not begin with 99.</eg>

<p>This is not possible since the translated message contains the context where the
rule has been applied:</p>
<eg xml:space="preserve">&lt;sch:value-of select="string(u:ID)"/&gt;</eg>
<p>
To be able to re-use this message, the schema author must 
be able to substitute <code>u:ID</code> in <code>&lt;sch:value-of select="u:ID "/&gt;</code> with 
some content that is appropriate for the context in which the message is used. In order
to do that, the translation messages should substitute this context with a generic value.
</p>
<eg xml:space="preserve">
StudentIDErrorMsg = L'identifieur specifie &lt;sch:value-of select="string(u:ID)"/&gt; ne commence pas par 99.
StudentIDErrorMsg = Das angegebene Attributkennzeichen ID &lt;sch:value-of select="string(u:ID)"/&gt; beginnt nicht mit 99.
</eg>
<p>
In other words, instead of the messages shown above, the translation
files should contain messages where the context of the Schematron rule
is being replaced with a generic variable.
</p>
<eg xml:space="preserve">
StudentIDErrorMsg = L'identifieur specifie &lt;sch:value-of select="string($var)"/&gt; ne commence pas par 99.
StudentIDErrorMsg = Das angegebene Attributkennzeichen ID &lt;sch:value-of select="string($var)"/&gt; beginnt nicht mit 99.
</eg>
<p>
The error message in <code>sch:assert</code> identified by the 
<code>lang:StudentIDErrorMsg</code> value can now be reused in contexts
other than the one described by the above sample.
</p>
<p>The sample below shows how substitution variable support can be achieved on Schematron 
<code>sch:assert</code> messages by using <code>xsl:variable</code> support:
</p>
<eg xml:space="preserve">
&lt;sch:schema xmlns:sch="http://purl.oclc.org/dsdl/schematron"
            xmlns:lang="http://www.university.example.org/translation/"&gt;
    &lt;sch:ns prefix="u" uri="http://www.university.example.org/ns" /&gt;
    &lt;sch:ns prefix="smlfn" uri="http://www.w3.org/ns/sml-function"/&gt;
    &lt;sch:pattern id="StudentPattern”&gt;
        &lt;sch:rule context="u:Students/u:Student"&gt;
            &lt;sch:assert test="smlfn:deref(.)[starts-with(u:ID,'99')]"
                        sml:locid="lang:StudentIDErrorMsg"&gt;
                &lt;xsl:variable name="var” select=”u:ID” /&gt;
                The specified ID &lt;sch:value-of select="string($var)"/&gt; does not begin with 99.
            &lt;/sch:assert&gt;
        &lt;/sch:rule&gt;
    &lt;/sch:pattern&gt;
&lt;/sch:schema&gt;
</eg>

<p>
The error message in <code>sch:assert</code> and the localization identifier 
<code>lang:StudentIDErrorMsg</code> can now be reused in contexts
other than <code>u:Students/u:Student</code>.
</p>

</inform-div1>
      
<inform-div1 id="Acknowledgements">
<head>Acknowledgements</head>

<p>The editors acknowledge the members of the Service Modeling Language Working
Group, the members of other W3C Working Groups, and industry experts
in other forums who have contributed directly or indirectly to the
process or content of creating this document.</p>
<p>At the time this specification was published, the members of the
Service Modeling Language Working Group were:</p>

<p>John Arwe (IBM Corporation), Len Charest (Microsoft Corporation), Sandy Gao (IBM Corporation), Paul Lipton (CA), James Lynn (HP), Kumar Pandit (Microsoft Corporation), Valentina Popescu (IBM Corporation), Virginia Smith (HP), Michael Sperberg-McQueen (W3C/MIT), David Whiteman (IBM Corporation), Kirk Wilson (CA).</p>

<p>The Service Modeling Language Working Group has benefited in its work
from the participation and contributions of a number of people not currently
members of the Working Group, including in particular those named below.</p>

<p>Dave Ehnebuske (IBM), Jon Hass (Dell), Steve Jerman (Cisco), Heather Kreger (IBM), Vincent Kowalski (BMC), Milan Milenkovic (Intel), Bryan Murray (HP), Phil Prasek (HP), Junaid Saiyed (EMC), Harm Sluiman (IBM), Bassam Tabbara (Microsoft), Vijay Tewari (Intel), William Vambenepe (HP), Marv Waschke (CA), Andrea Westerinen (Microsoft), Pratul Dublish (Microsoft), Julia McCarthy (IBM).
</p>

<p>Affiliations given above are those current at the time of their work with the working group. 
</p>
</inform-div1>

    </back>
</spec>