<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/css" href="is.css" ?>

<document >

<!-- ==========================================================-->
<annex normative="true" id="binding">
<title>Default Query Language Binding</title>
<p>A Schematron schema with no language binding or a <code>queryBinding</code>
attribute with the value <code>xslt</code>, in any mix of upper and lower case letters, 
shall use the following binding:</p>
<ul>
<li><p>The query language used is the extended version of
<xref to="xpath-rec"/> specified in <xref to="xslt-rec"/>.
Consequently, the data model used is the data model of those
specifications.</p></li>
<li><p>The rule context is interpreted according to the Production
1 of <xref to="xslt-rec"/>. The rule context may be elements, attributes, 
comments and processing instructions.</p></li>
<li><p>The assertion test is interpreted according to 
Production 14 of <xref to="xpath-rec"/>, as returning a Boolean value.</p></li>
<li><p>The name query is interpreted according to
Production 14  of <xref to="xpath-rec"/>, as returning a string value.
Typically, the <code>select</code> attribute contains an expression
returning an element node: the name query takes the local or prefixed name of the
node, not its value.</p></li>
<li><p>The value-of query is interpreted according to Production
14 of <xref to="xpath-rec"/>, as returning a string value.</p></li>

<li><p>The let value is interpreted according to Production
14 of <xref to="xpath-rec"/>, as returning a string value.</p></li>

<li><p>The notation for signifying the use of parameter of an abstract pattern is to prefix
the name token with the <strong>$</strong> character. 
This is a character not found as a delimiter in URLs or XPaths.
The <strong>$</strong> character not followed by the name
of an in-scope parameter shall not be
treated as a parameter name delimiter. Such a character may 
subsequently be used as a delimiter for a variable name or as
a literal character. </p></li>

<li><p>A Schematron let expression is treated 
as an <xref to="xslt-rec"/> variable. The <xref to="xslt-rec"/> $ delimiter signifies the use
of a variables in an context expression, assertion test, name query, value-of
query or let expression.
The <strong>$</strong> character not followed by the name
of an in-scope variable shall be
treated as a literal character.</p></li>

</ul>

<p>The <xref to="xslt-rec"/> <code>key</code> element may be used, in
the <xref to="xslt-rec"/> namespace, before the pattern elements.</p>
<p>The attributes <code>id</code>, <code>name</code> and <code>prefix</code> should
follow the rules for non-colonized names 
for the version of XML used by the document.
</p>
</annex>
<!-- ==========================================================-->

<annex normative="false"  id="svrl">
<title>Schematron Validation Report Language</title>
<clause>
<title>Description</title>
<p>The Schematron Validation Report Language (SVRL) is
a simple XML language which may be used for reporting the
results of Schematron validation and for conformance
suites. 
</p>
<p>The order of elements in an SVRL is implementation-dependent;
different implementations may generate the same elements in
a different order.</p>
<p>All elements shown in the grammar for Simple Validation Report Language 
are qualified with the namespace
URI:</p>

<pre>http://purl.oclc.org/dsdl/svrl</pre>

<p>In subsequent schemas, the prefix <code>svrl</code> is taken as
bound to the Simple Validation Report Language namespace URI for exposition purposes.
The prefix <code>svrl</code> is not reserved or required by
this part of ISO/IEC 19757. 
</p>

</clause>
<clause>
<title>RELAX NG Compact Syntax Schema</title>
<pre xml:space="preserve" ><![CDATA[<!--
       (c) International Organization for Standardization 2005. 
       Permission to copy in any form is granted for use with conforming 
       SGML systems and applications as defined in ISO 8879, 
       provided this notice is included in all copies.
 -->
default namespace = "http://purl.oclc.org/dsdl/svrl"

schematron-output   element schematron-output {
  	attribute title { text }?,
  	attribute phase { xsd:NMTOKEN }?,
  	attribute schemaVersion { text }?,
    human-text*,
    ns-prefix-in-attribute-values*,
    (active-pattern,
     (fired-rule, (failed-assert | successful-report)*)+)+
  }
  
# only namespaces from sch:ns need to be reported
ns-prefix-in-attribute-values   element ns-prefix-in-attribute-values { 
    attribute prefix { xsd:NMTOKEN },
    attribute uri { text }, 
    empty
  }
    
# only active patterns are reported
active-pattern   element active-pattern { 
  	attribute id { xsd:ID }?,
 	attribute name { text }?,
 	attribute role { xsd:NMTOKEN }?, 
  	empty 
  }
    
# only rules that are fired are reported, 
fired-rule = 
  element fired-rule { 
  	attribute id { xsd:ID }?,
  	attribute context { text },
  	attribute role { xsd:NMTOKEN }?,
  	attribute flag { xsd:NMTOKEN }?, 
	empty 
  }

# only references are reported, not the diagnostic
diagnostic-reference   element diagnostic-reference { 
  	attribute diagnostic { xsd:NMTOKEN }, 
  	human-text 
  }
# only failed assertions are reported
failed-assert   element failed-assert {
    attlist.assert-and-report, 
    diagnostic-reference*, 
    human-text
  }

# only successful asserts are reported
successful-report   element successful-report {
    attlist.assert-and-report, 
    diagnostic-reference*, 
    human-text
  }
  
human-text = element text { text }

attlist.assert-and-report   attribute id { xsd:ID }?,
  attribute location { text },
  attribute test { text },
  attribute role { xsd:NMTOKEN }?,
  attribute flag { xsd:NMTOKEN }?
  
start = schematron-output
]]></pre>

</clause>
<clause>
<title>Schematron Schema</title>
<p>The corresponding Schematron schema is:</p>
<pre xml:space="preserve"><![CDATA[<!--
       (c) International Organization for Standardization 2005. 
       Permission to copy in any form is granted for use with conforming 
       SGML systems and applications as defined in ISO 8879, 
       provided this notice is included in all copies.
 -->
 
<sch:schema 
    xmlns:sch="http://purl.oclc.org/dsdl/schematron" 
    xml:lang="en" >
 
    <sch:title>Schema for Schematron Validation Report Language</sch:title>
    <sch:ns prefix="svrl" uri="http://purl.oclc.org/dsdl/svrl" />    
    
    <sch:p>The Schematron Validation Report Language is a simple language 
        for implementations to use to compare their conformance. It is 
        basically a list of all the assertions that fail when validating 
        a document, in any order, together with other information such 
        as which rules fire.
    </sch:p>
    <sch:p>This schema can be used to validate SVRL documents, and provides
        examples of the use of abstract rules and abstract patterns.</sch:p>
    
    <sch:pattern>
        <sch:title>Elements</sch:title>

        <!--Abstract Rules -->
        <sch:rule abstract="true" id="second-level">
            <sch:assert test="../svrl:schematron-output">
                The <sch:name/> element is a child of schematron-output.
            </sch:assert>
        </sch:rule>
        
        <sch:rule abstract="true" id="childless">
            <sch:assert test="count(*)=0"> 
                The <sch:name/> element should not contain any elements.
            </sch:assert>
        </sch:rule>

        <sch:rule abstract="true" id="empty">
            <sch:extends rule="childless" />
            <sch:assert test="string-length(space-normalize(.)) = 0">
                The <sch:name/> element should be empty.
            </sch:assert>
        </sch:rule>
        
        <!-- Rules-->
        <sch:rule context="svrl:schematron-output">
            <sch:assert test="not(../*)">
                The <sch:name/> element is the root element.
            </sch:assert>
            <sch:assert 
                test="count(svrl:text) + count(svrl:ns-prefix-in-attribute-values) + count(svrl:active-pattern) +
                    count(svrl:fired-rule) + count(svrl:failed-assert) +
                    count(svrl:successful-report) = count(*)">
                <sch:name/> may only contain the following elements: 
                text, ns-prefix-in-attribute-values, active-pattern, fired-rule, failed-assert 
                and successful-report.
            </sch:assert>
            <sch:assert test="svrl:active-pattern">
                <sch:name/> should have at least one active pattern.
            </sch:assert>
        </sch:rule>
        
        <sch:rule context="svrl:text">
            <sch:extends rule="childless" />
        </sch:rule>
        
        <sch:rule context="svrl:diagnostic-reference">
            <sch:extends rule="childless" />
            <sch:assert test="string-length(@diagnostic) &gt; 0">
                <sch:name/> should have a diagnostic attribute, 
                giving the id of the diagnostic.
            </sch:assert>
        </sch:rule>
        
        <sch:rule context="svrl:ns-prefix-in-attribute-values">
            <sch:extends rule="second-level" />
            <sch:extends rule="empty" />
            <sch:assert 
                test="following-sibling::svrl:active-pattern 
                      or following-sibling::svrl:ns-prefix-in-attribute-value"> 
                A <sch:name/> comes before an active-pattern or another 
                ns-prefix-in-attribute-values element.
            </sch:assert>
        </sch:rule>
        
        <sch:rule context="svrl:active-pattern">
            <sch:extends rule="second-level" />
            <sch:extends rule="empty" />
        </sch:rule>
        
        <sch:rule context="svrl:fired-rule">
            <sch:extends rule="second-level" />
            <sch:extends rule="empty" />
            <sch:assert 
                test="preceding-sibling::active-pattern |
                    preceding-sibling::svrl:fired-rule |
                    preceding-sibling::svrl:failed-assert |
                    preceding-sibling::svrl:successful-report">
                A <sch:name/> comes after an active-pattern, an empty 
                fired-rule, a failed-assert or a successful report.
            </sch:assert>
            <sch:assert test="string-length(@context) &gt; 0">
                The <sch:name/> element should have a context attribute 
                giving the current context, in simple XPath format.
            </sch:assert> 
        </sch:rule>
        
        <sch:rule context="svrl:failed-assert | svrl:successful-report">
            <sch:extends rule="second-level" />
            <sch:assert 
                test="count(svrl:diagnostic-reference) + count(svrl:text) = count(*)"> 
                The <sch:name/> element should only contain a text element 
                and diagnostic reference elements.
            </sch:assert>
            <sch:assert test="count(svrl:text) = 1"> 
                The <sch:name/> element should only contain a text element.
            </sch:assert>
            <sch:assert test="preceding-sibling::svrl:fired-rule |
                preceding-sibling::svrl:failed-assert |
                preceding-sibling::svrl:successful-report"> 
                A <sch:name/> comes after a fired-rule, a failed-assert or a
                successful-report.
            </sch:assert>
        </sch:rule>
        
        <!-- Catch-all rule-->
        <sch:rule context="*">
            <sch:report test="true()">
                An unknown <sch:name/> element has been used.
            </sch:report>
        </sch:rule>
    </sch:pattern>
    
    <sch:pattern>
        <sch:title>Unique Ids</sch:title>
        
        <sch:rule context="*[@id]">
            <sch:assert test="not(preceding::*[@id=current()/@id][1]"> 
                Id attributes should be unique in a document.
            </sch:assert>
        </sch:rule>
    </sch:pattern>
    
    <sch:pattern abstract="true" id="requiredAttribute">
        <sch:title>Required Attributes</sch:title>
        
        <sch:rule context=" $context ">
            <sch:assert test="string-length( $attribute ) &gt; 0">
                The <sch:name/> element should have a 
                <sch:value-of select="$attribute /name()" /> attribute.
            </sch:assert> 
        </sch:rule>
    </sch:pattern>
    
    <sch:pattern is-a="requiredAttribute">
        <sch:param name="context" value="svrl:diagnostic-reference" />
        <sch:param name="attribute" value="@diagnostic" />
    </sch:pattern>    
    
    <sch:pattern is-a="requiredAttribute">
        <sch:param name="context" value="svrl:failed-assert or svrl:successful-report" />
        <sch:param name="attribute" value="@location" />
    </sch:pattern>    
    
    <sch:pattern is-a="requiredAttribute">
        <sch:param name="context" value="svrl:failed-assert or svrl:successful-report" />
        <sch:param name="attribute" value="@test" />
    </sch:pattern>    

    <sch:pattern is-a="requiredAttribute">
        <sch:param name="context" value="svrl:ns-prefix-in-attribute-values" />
        <sch:param name="attribute" value="@uri" />
    </sch:pattern>    
    
    <sch:pattern is-a="requiredAttribute">
        <sch:param name="context" value="svrl:ns-prefix-in-attribute-values" />
        <sch:param name="attribute" value="@prefix" />
    </sch:pattern>                
    
</sch:schema>]]>

</pre>
</clause>
</annex> 


<annex normative = "false"  id="req" >
<title>Design Requirements</title>
<p>Motivating design requirements for the schema language with the default
query language binding include:</p>
<ol>
<li><p>Represent abstract patterns such as the <i>head+body</i> pattern.</p></li>
<li><p>Support progressive validation.</p></li>
<li><p>Include assertions or abstract rules from an external file.</p></li>
<li><p>Support a one-to-one mapping between the natural-language
statements and artificial-language statements.</p></li>
<li><p>Support the generation and labelling of arcs between information items.</p></li>
</ol>

<p>Motivating  design requirements for the schema language with the default
query language binding do not include:</p>
<ul>
<li><p>Simple specification of constraints that are simply expressed by grammar-based validation,
such as ISO/IEC 19757-2 (RELAX NG) schemas.</p></li>
<li><p>Replacement of any other standard schema language for XML.</p></li>
<li><p>Single-pass or streamable implementation.</p></li>
</ul>


<p>As well, certain outcomes are out-of-scope for this part of ISO/IEC 19757:</p>
<ul>
<li><p>Specification of a type system.</p><!-- no PSVI --></li>
<li><p>Generation of links between multiple occurrences of
some datum across multiple documents for the purpose of consistency-checking.</p><!-- XLinkIt patent --></li>

</ul>

</annex>

<!-- NEW BINDINGs -->


<!-- ==========================================================-->
<annex normative="true" id="xpath2-binding">
<title>Query Language Binding for XPath 2</title>

<p>The <code>xpath2</code> query language binding allows schemas
implemented using the simplest 
</p>


<p>A Schematron schema with a <code>queryBinding</code>
attribute with the value <code>xpath2</code>, in any mix of upper and lower case letters, 
shall use the following binding:</p>
<ul>
<li><p>The query language used is that of <xref to="xpath2-rec"/>
used with no <xref to="xsd-ref"/> schema and
with backwards compatability mode as false.
Consequently, the data model used is the data model of
<xref to="xpath2-model"/> contructed from an infoset not a PSVI.
All namespaces, prefixes, functions and operators defined by 
<xref to="xpath2-functions"/> shall be available.
No user-written functions or extensions shall be available.</p></li>
<li><p>The rule context is interpreted according to the Production
Production 1 of <xref to="xpath2-rec"/>. The rule context may be elements, attributes, 
comments and processing instructions, including sequences of these.</p></li>
<li><p>The assertion test is interpreted according to 
Production 1 of <xref to="xpath2-rec"/>, 
using <code>fn:boolean()</code> on the result of evaluating the expression
and to find the effective boolean value.</p></li>
<li><p>The name query is interpreted according to
Production 1 of <xref to="xpath2-rec"/>, 
using <code>fn:node-name()</code> on the result of evaluating the expression
which should be an element or attribute node
and returning a string value.
</p></li>
<li><p>The value-of query is interpreted according to Production
Production 1 of <xref to="xpath2-rec"/>, 
using <code>fn:string()</code> on the result of evaluating the expression
and returning a string value.</p></li>

<li><p>The let element should not be used.</p></li>
 
<li><p>Abstract patterns and parameters should not be used.</p></li>

</ul>
 
<p>The attributes <code>id</code>, <code>name</code> and <code>prefix</code> should
follow the rules for non-colonized names 
for the version of XML used by the document.</p>

<p>The <code>fn:error()</code> function  or other dynamic errors
should not be used to provide assertion text
or to substitute for assertions and diagnostics.
</p>

</annex>




<!-- ==========================================================-->
<annex normative="true" id="xslt2-binding">
<title>Query Language Binding for XSLT 2</title>

<p>The <code>xslt2</code> query language binding allows schemas
implemented using <xref to="xslt2-rec"/>. All implementations
that support the <code>xslt2</code> query language binding should also support 
<code>xpath2</code> query language binding. 
</p>


<p>A Schematron schema with a <code>queryBinding</code>
attribute with the value <code>xslt2</code>, in any mix of upper and lower case letters, 
shall use the following binding:</p>
<ul>
<li><p>The query language used is the extended version of
 <xref to="xpath2-rec"/> specified in <xref to="xslt2-rec"/>
with backwards compatability mode as false.
Consequently, the data model used is the data model of
<xref to="xpath2-model"/> contructed from an infoset or a PSVI.
All namespaces, prefixes, functions and operators defined by 
<xref to="xpath2-functions"/> shall be available.
An implementation may allow user-written functions and extensions,
in the appropriate namespace.</p></li>
<li><p>The rule context is interpreted according to the Production
Production 1 of <xref to="xslt2-rec"/>. The rule context may be elements, attributes, 
comments and processing instructions, including sequences of these.</p></li>
<li><p>The assertion test is interpreted according to 
Production 1 of <xref to="xpath2-rec"/>, 
using <code>fn:boolean()</code> on the result of evaluating the expression
and to find the effective boolean value.</p></li>
<li><p>The name query is interpreted according to
Production 1 of <xref to="xpath2-rec"/>, 
using <code>fn:node-name()</code> on the result of evaluating the expression
which should be an element or attribute node
and returning a string value.
</p></li>
<li><p>The value-of query is interpreted according to Production
Production 1 of <xref to="xpath2-rec"/>, 
using <code>fn:string()</code> on the result of evaluating the expression
and returning a string value.</p></li>
 
<li><p>The let value is interpreted according to Production
Production 1 of <xref to="xpath2-rec"/>.</p></li>

<li><p>The notation for signifying the use of parameter of an abstract pattern is to prefix
the name token with the <strong>$</strong> character. 
This is a character not found as a delimiter in URLs or XPaths.
The <strong>$</strong> character not followed by the name
of an in-scope parameter shall not be
treated as a parameter name delimiter. Such a character may 
subsequently be used as a delimiter for a variable name or as
a literal character. </p></li>

<li><p>A Schematron let expression is treated 
as an <xref to="xslt2-rec"/> variable. The <xref to="xslt2-rec"/> $ delimiter signifies the use
of a variables in an context expression, assertion test, name query, value-of
query or let expression.
The <strong>$</strong> character not followed by the name
of an in-scope variable shall be
treated as a literal character.</p></li>


<li><p>All namespaces and prefixes defined by <xref to="xslt2-rec"/> for modules are reserved
 with their <xref to="xslt2-rec"/>
usage. All functions defined by these modules shall be available in addition to the the functions defined 
by <xref to="xpath2-functions"/>.
 </p></li>
</ul>

<p>The <xref to="xslt2-rec"/> <code>key</code> element may be used, in
the <xref to="xslt2-rec"/> namespace, before the pattern elements.</p>


<p>The <xref to="xslt2-rec"/> <code>function</code> element may be used, in
the <xref to="xslt2-rec"/> namespace, before the pattern elements.</p>

<p>The attributes <code>id</code>, <code>name</code> and <code>prefix</code> should
follow the rules for non-colonized names 
for the version of XML used by the document.</p>

<p>The <code>fn:error()</code> function or other dynamic errors
 should not be used to provide assertion text
or to substitute for assertions and diagnostics. 
</p>


</annex>



<!-- ======================= -->


<annex normative="false" id="exslt-binding">
<title>Query Language Binding for EXSLT</title>

<p>The <code>exslt</code> query language binding is the default <code>xslt</code> binding
augmented by the <xref to="exslt-rec"/> functions.
</p>

<p>A Schematron schema with a <code>queryBinding</code>
attribute with the value <code>exslt</code>, in any mix of upper and lower case letters, 
shall use the following binding:</p>

<ul>
<li><p>The query language used is the extended version of
<xref to="xpath-rec"/> specified in <xref to="xslt-rec"/>.
Consequently, the data model used is the data model of those
specifications.</p></li>
<li><p>The rule context is interpreted according to the Production
1 of <xref to="xslt-rec"/>. The rule context may be elements, attributes, 
comments and processing instructions.</p></li>
<li><p>The assertion test is interpreted according to 
Production 14 of <xref to="xpath-rec"/>, as returning a Boolean value.</p></li>
<li><p>The name query is interpreted according to
Production 14  of <xref to="xpath-rec"/>, as returning a string value.
Typically, the <code>select</code> attribute contains an expression
returning an element node: the name query takes the local or prefixed name of the
node, not its value.</p></li>
<li><p>The value-of query is interpreted according to Production
14 of <xref to="xpath-rec"/>, as returning a string value.</p></li>

<li><p>The let value is interpreted according to Production
14 of <xref to="xpath-rec"/>, as returning a string value.</p></li>

<li><p>The notation for signifying the use of parameter of an abstract pattern is to prefix
the name token with the <strong>$</strong> character. 
This is a character not found as a delimiter in URLs or XPaths.
The <strong>$</strong> character not followed by the name
of an in-scope parameter shall not be
treated as a parameter name delimiter. Such a character may 
subsequently be used as a delimiter for a variable name or as
a literal character. </p></li>

<li><p>A Schematron let expression is treated 
as an <xref to="xslt-rec"/> variable. The <xref to="xslt-rec"/> $ delimiter signifies the use
of a variables in an context expression, assertion test, name query, value-of
query or let expression.
The <strong>$</strong> character not followed by the name
of an in-scope variable shall be
treated as a literal character.</p></li>

<li><p>All namespaces and prefixes defined by <xref to="exslt-rec"/> for modules are reserved
 with their <xref to="exslt-rec"/>
usage. All functions defined by these modules shall be available in addition to the the functions defined 
by Production 14 of <xref to="xpath-rec"/> and 
Production
1 of <xref to="xslt-rec"/>
 </p></li>
</ul>

<note><p>As <xref to="exslt-rec"/> does not require all implementations to provide all
modules, some schemas using this query language binding will fail if they use functions
which the implementation does not provide.</p></note>

<p>The <xref to="xslt-rec"/> <code>key</code> element may be used, in
the <xref to="xslt-rec"/> namespace, before the pattern elements.</p>
<p>The attributes <code>id</code>, <code>name</code> and <code>prefix</code> should
follow the rules for non-colonized names 
for the version of XML used by the document.
</p>
</annex>

<!-- NEW BINDING FOR STX -->

<!-- ==========================================================-->
<annex normative="true" id="stx-binding">
<title>Query Language Binding for STX</title>

<p>The <code>stx</code> query language binding provides a schema langauge
suited to memory-efficient streaming implementation.
</p>

<p>A Schematron schema with a <code>queryBinding</code>
attribute with the value <code>stx</code>, in any mix of upper and lower case letters, 
shall use the following binding:</p>
<ul>
<li><p>The query language used is the streaming dialect of
<xref to="xpath-rec"/> specified in <xref to="stx-rec"/>.
Consequently, the data model used is the data model of <xref to="stx-rec"/>
which is a variant on <xref to="xpath-model"/> noting that
all elements and attributes are treated as untyped in <xref to="stx-rec"/>.</p></li>
<li><p>The rule context is interpreted according to the Production
2 of <xref to="stx-rec"/>. The rule context may be elements, attributes, 
comments and processing instructions.</p></li>
<li><p>The assertion test is interpreted according to 
Production 1 of <xref to="stx-rec"/>, as returning a Boolean value.</p></li>
<li><p>The name query is interpreted according to
Production 1  of <xref to="stx-rec"/>, as returning a string value.
Typically, the <code>select</code> attribute contains an expression
returning an element node: the name query takes the local or prefixed name of the
node, not its value.</p></li>
<li><p>The value-of query is interpreted according to Production
1 of <xref to="stx-rec"/>, as returning a string value.</p></li>

<li><p>The let value is interpreted according to Production
1 of <xref to="stx-rec"/>, as returning a string value.</p></li>

<li><p>The notation for signifying the use of parameter of an abstract pattern is to prefix
the name token with the <strong>$</strong> character. 
This is a character not found as a delimiter in URLs or XPaths.
The <strong>$</strong> character not followed by the name
of an in-scope parameter shall not be
treated as a parameter name delimiter. Such a character may 
subsequently be used as a delimiter for a variable name or as
a literal character. </p></li>

<li><p>A Schematron let expression is treated 
as an <xref to="stx-rec"/> variable. The <xref to="stx-rec"/> $ delimiter signifies the use
of a variables in an context expression, assertion test, name query, value-of
query or let expression.
The <strong>$</strong> character not followed by the name
of an in-scope variable shall be
treated as a literal character.</p></li>

</ul>
 
<p>The attributes <code>id</code>, <code>name</code> and <code>prefix</code> should
follow the rules for non-colonized names 
for the version of XML used by the document.</p>

<p>The <code>message</code> element shall not be used to provide text for assertions
and diagnostics.</p>


</annex>

</document>