<?xml version="1.0" encoding="utf-8"?>
<!--
  (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.
-->


<grammar 
xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0" 
xmlns="http://relaxng.org/ns/structure/1.0"

    ns="http://purl.oclc.org/dsdl/svrl"
    xmlns:ns1="http://www.dpawson.co.uk/rss/ns#" 

    xmlns:rng="http://relaxng.org/ns/structure/1.0" 

    xmlns:html ="http://www.w3.org/1999/xhtml"
    xmlns:dc="http://purl.org/dc/elements/1.1/"
    datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">


  <a:documentation>
    <html:h2>ISO /IEC 19757-3:2006</html:h2>
    <html:p>Revision 1.0 </html:p>
    <html:p> (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.  </html:p>

    <dc:identifier>http://www.dpawson.co.uk/schematron/isoSchematron.rng</dc:identifier>
         <dc:creator>Dave Pawson</dc:creator>
         <dc:dateCreated>2007-01-26T10:51:30.0Z</dc:dateCreated>
         <dc:isPartOf>ISO/IEC 19757-3:2006</dc:isPartOf>
         <dc:publisher>http://www.dpawson.co.uk</dc:publisher>
         <dc:rights>&#xA9; Dave Pawson,  2007 </dc:rights>  
         <dc:creator>Dave Pawson</dc:creator>
        <a:revhistory>
              <a:revision>
                   <a:revnumber>1.0</a:revnumber>
                   <a:date>2007-01-24T10:56:47.0Z</a:date>
                   <a:authorinitials>Dave P</a:authorinitials>
                   <a:revremark>Initial release. This file is modification of the version in Annex D of the standard</a:revremark>
		   
              </a:revision>
              <a:revision>
                   <a:revnumber>1.1</a:revnumber>
                   <a:date>2007-01-28T09:31:16Z</a:date>
                   <a:authorinitials>Dave P</a:authorinitials>
                   <a:revremark>Amended in light of usage. View the
                   .rng file to see actual changes. </a:revremark>
              </a:revision>

             <a:revision>
                   <a:revnumber>1.2</a:revnumber>
                   <a:date>2007-01-31T11:08:35.0Z</a:date>
                   <a:authorinitials>Dave P</a:authorinitials>
                   <a:revremark>Amended in light of usage. Added span and emph elements to text</a:revremark>
              </a:revision>

            <a:revision>
                   <a:revnumber>1.3</a:revnumber>
                   <a:date>2007-02-01T18:35:44.0Z</a:date>
                   <a:authorinitials>Dave P</a:authorinitials>
                   <a:revremark>Updated to include decorative elements.</a:revremark>
              </a:revision>


 
        </a:revhistory>
  </a:documentation>

<div html:id="root">
    <html:h3>Document element</html:h3>
  <start>
    <ref name="Schematron-output"/>
  </start>
</div>

<div html:id="schematron-output"> 
<html:h3>Element schematron-output</html:h3> 
<html:p>The root element of the svrl format </html:p>
<html:p>The optional title attribute is derived from iso:schema/iso:title element.</html:p>
<html:p>The optional phase attribute is apparently unused? @FIXME</html:p>
<html:p>The schemaVersion attribute is derived from the iso:schema/@schemaVersion attribute</html:p>
<html:p></html:p> 
  <define name="Schematron-output">
    <element name="schematron-output">
      <optional>
        <attribute name="title"/>
      </optional>
      <optional>
        <attribute name="phase">
          <data type="NMTOKEN"/>
        </attribute>
      </optional>
      <optional>
        <attribute name="schemaVersion"/>
      </optional>

      <zeroOrMore>
        <ref name="Human-text"/>
      </zeroOrMore>
      <zeroOrMore>
        <ref name="Ns-prefix-in-attribute-values"/>
      </zeroOrMore>
      <oneOrMore>
        <ref name="Active-pattern"/>
        <oneOrMore>
          <ref name="Fired-rule"/>
          <zeroOrMore>
            <choice>
              <ref name="Failed-assert"/>
              <ref name="Successful-report"/>
            </choice>
          </zeroOrMore>
        </oneOrMore>
      </oneOrMore>
    </element>
  </define>
</div>



  <!-- only namespaces from sch:ns need to be reported -->
<div html:id="ns-prefix-in-attribute-values"> 
<html:h3>Element ns-prefix-in-attribute-values </html:h3> 
<html:p>Provides the output file with ready access to foreign
namespaces defined in the Schematron schema. Derived from the iso:ns
element in Schematron. The attribute prefix provides the ns prefix,
the uri provides the namespace. </html:p>
  <define name="Ns-prefix-in-attribute-values">
    <element name="ns-prefix-in-attribute-values">
      <attribute name="prefix">
<!-- Datatype changed to NCName from NMTOKEN. DP  -->
        <data type="NCName"/>
      </attribute>
      <attribute name="uri">
	<data type="anyURI"/>
      </attribute>
      <empty/>
    </element>
  </define>
</div>


  <!-- only active patterns are reported -->
<div html:id="active-pattern"> 
  <html:h3>Element active-pattern</html:h3> 
  <html:p>Reports on which patterns are active in this phase. Derived
  from the iso:active/@pattern attribute in the Schematron schema. Both
  the name and id values appear to be derived from the pattern
  attribute.  It would appear that the role attribute is unused
  @FIXME</html:p>
  <html:p>2007-01-27T10:54:45Z. Added foreign-nodes reference.</html:p>
  <define name="Active-pattern">
    <element name="active-pattern">
      <optional>
	<attribute name="id">
	  <data type="ID"/>
	</attribute>
      </optional>
      <optional>
	<attribute name="name"/>
      </optional>
      <optional>
	<attribute name="role">
	  <data type="NMTOKEN"/>
	</attribute>
      </optional>
      <!-- Added optional Rich outputs DP -->
      <ref name="Rich"/>
      
      <!-- DP added title as child-->
      <optional>
	<element name="title">
	  <mixed>
	    <zeroOrMore>
	      <ref name="Dir"/>
	    </zeroOrMore>
	  </mixed>
	</element>
      </optional>
	<zeroOrMore>
	  <ref name="Text"/>
	</zeroOrMore> 
    </element>
  </define>
</div>



  <!-- only rules that are fired are reported, -->
<div html:id="fired-rule"> 
<html:h3>Element fired-rule</html:h3> 
<html:p>Each time a rule is fired it is reported by a line in the
output file, reporting the context in which the rule fired.  the
context attribute is derived from iso:rule/@context.  the id, role and
flag attributes require generation by the schema author, by means of template overrides. @FIXME</html:p>
  <define name="Fired-rule">
    <element name="fired-rule">
      <optional>
        <attribute name="id">
          <data type="ID"/>
        </attribute>
      </optional>
      <attribute name="context"/>
      <optional>
        <attribute name="role">
          <data type="NMTOKEN"/>
        </attribute>
      </optional>
      <optional>
        <attribute name="flag">
          <data type="NMTOKEN"/>
        </attribute>
      </optional>
      <empty/>
    </element>
  </define>
</div>

  <!-- only references are reported, not the diagnostic -->
<div html:id="diagnostic-reference"> 
<html:h3>Element diagnostic-reference</html:h3> 
<html:p>Reports the dignostic used, by means of the diagnostic
attribute of this element. The value is derived from the diagnostics
attribute on iso:assert and iso:report. </html:p>
  <define name="Diagnostic-reference">
    <element name="diagnostic-reference">
      <attribute name="diagnostic">
        <data type="NMTOKEN"/>
      </attribute>
	<ref name='Rich'/>
	<ref name='Linkable'/>
      <ref name="Human-text"/>
    </element>
  </define>
</div>


  <!-- only failed assertions are reported -->
<div html:id="failed-assert"> 
<html:h3>Element failed-assert</html:h3> 
<html:p>Reports on an assertion that has failed. The test attribute
reports the test undertaken. If set to operate, the location attribute
reports the source document location and the contained text reports
the assertion message. Diagnostics may be included if referenced from
the iso:assert element by the diagnostics attribute. </html:p>
  <define name="Failed-assert">
    <element name="failed-assert">
      <ref name="Attlist.assert-and-report"/>
      <zeroOrMore>
	<ref name="Human-text"/>
      </zeroOrMore>
      
      <zeroOrMore>
	<ref name="Diagnostic-reference"/>
      </zeroOrMore>
      <empty/>
    </element>
  </define>
</div>



  <!-- only successful asserts are reported -->
<div html:id="successful-report"> 
<html:h3>Element successful-report </html:h3> 
<html:p>Reports on an assertion that has passed. The test attribute
reports the test undertaken. If set to operate, the location attribute
reports the source document location and the contained text reports
the assertion message. Diagnostics may be included if referenced from
the iso:assert element by the diagnostics attribute.  </html:p> 
  <define name="Successful-report">
    <element name="successful-report">
      <ref name="Attlist.assert-and-report"/>
      <zeroOrMore>
        <ref name="Diagnostic-reference"/>
      </zeroOrMore>
      <ref name="Human-text"/>
    </element>
  </define>
</div>


<div html:id="text"> 
<html:h3>Element text</html:h3> 
<html:p>Basic paragraph. to help with documentation. Styling can be
aided with the class attribute and the icon attribute. It may contain
foreign elements. </html:p>
<define name="Text"> 
  <element name="text"> 
    <optional>
      <attribute name="id">
	<data type="ID"/>
      </attribute>
    </optional>
    <optional>
      <attribute name="class">
	<text/>
      </attribute>
    </optional>
    <optional>
      <attribute name="icon">
	<data type ="anyURI"/>
      </attribute>
    </optional>
    <interleave>
      <ref name="Foreign-nodes"/>
      <zeroOrMore>
	<choice>
	  <text/>
	  <ref name="Dir"/>
	  <ref name="Emph"/>
	  <ref name="Span"/>
	</choice>
      </zeroOrMore>
    </interleave>
  </element> 
</define> 
</div>



<div html:id="human-text"> 
<html:h3>Element text </html:h3> 
<html:p>Valid within schematron-output, diagnostic-reference,
failed-assert and successful-report. </html:p>
<html:p>The text element is used as the general purpose text container
for report contents.</html:p>
  <define name="Human-text">
    <element name="text">
      <!-- Addition, DP. was <text/> Added emph and span-->
      <mixed>
	<choice>
	<ref name="Foreign-nodes"/>
	<zeroOrMore>
	  <choice>
	    <ref name="Emph"/>
	    <ref name="Span"/>
	    <ref name='Dir'/>
	    <ref name='Name'/>
	  </choice>
	</zeroOrMore>
	</choice>
      </mixed>
    </element>
  </define>
</div>


<div html:id="dir"> 
  <html:h3>Element dir</html:h3> 
  <html:p> </html:p> 
  <define name="Dir"> 
    <element name="dir"> 
      <attribute name='value'>
	<choice>
	  <value>ltr</value>
	  <value>rtl</value>
	</choice>
      </attribute>
      <interleave>
	<ref name="Foreign-nodes"/>
	<text/>
      </interleave>
    </element> 
  </define> 
</div>

<div html:id="name"> 
<html:h3>Element name </html:h3> 
<html:p>Provides  access to nodes in the input document. If
the optional path attribute is used, then the name of this node is
retrieved. Without the path attribute, the name of the current context
node is retrieved. </html:p>
  <define name="Name">
    <element name="name">
      <optional>
        <attribute name="path">
          <ref name="PathValue"/>
        </attribute>
      </optional>
      <ref name="Foreign-empty"/>
      <text/>
    </element>
  </define>
</div>



<div html:id="emph"> 
<html:h3>Element emph </html:h3> 
<html:p>A general purpose emphasis element </html:p> 
<define name='Emph'>
<element name="emph">
  <text/>
</element>
</define>

</div>

<div html:id="span"> 
<html:h3>Element span </html:h3> 
<html:p>A general purpose inline element, as per html, usage clarified by the class attribute </html:p> 
<define name='Span'>
<element name="span">
  <attribute name="class">
    <text/>
  </attribute>
  <mixed>
    <zeroOrMore>
      <ref name="Emph"/>
    </zeroOrMore>
  </mixed>
</element>
</define>

</div>


<div html:id="attlist.assert-and-report.att"> 
<html:h3>Element attlist.assert-and-report</html:h3> 
<html:p>This group of optional attributes provide additional information about a report entry.</html:p>
<html:p>The id attribute may be generated for linking purposes and is
generally copied over from the associate Schematron
assertion.</html:p>
<html:p>The location attribute identifies the xpath to the input
document at which the report was fired.</html:p>
<html:p>the test attribute reports the assertion test attribute contents.</html:p>
<html:p>The role attribute is generated by an author, in addition to
generic report content. It can help in styling output.</html:p>
<html:p>The flag attribute is added to the reported assertion, being
copied over from the iso:assert or iso:report. Although valid on iso:rule, this appears not to be used. @FIXME</html:p>
  <define name="Attlist.assert-and-report">
    <optional>
      <attribute name="id">
        <data type="ID"/>
      </attribute>
    </optional>
    <attribute name="location"/>
    <attribute name="test"/>
  
    <optional>
      <attribute name="flag">
        <data type="NMTOKEN"/>
      </attribute>
    </optional>
    <ref name='Rich'/>
    <ref name='Linkable'/>
  </define>
</div>


<!-- Addition by Dave Pawson DP -->

<div html:id="foreign-nodes"> 
<html:h3>Element 'foreign-nodes'</html:h3> 
<html:p>An element with attributes not in the Schematron namespace and not in the null namespace</html:p> 
<define name="Foreign-nodes">
  <zeroOrMore>
    <choice>
      <ref name="Foreign-attributes"/>
      <ref name="Foreign-elements"/>
    </choice>
  </zeroOrMore>
</define>
</div>



<div html:id="foreign-elements"> 
<html:h3>Element 'foreign'</html:h3> 
<html:p>An element not in the Schematron namespace </html:p> 
<define name="Foreign-elements">
  <zeroOrMore>
    <element>
      <anyName>
	<except>
	  <nsName ns=""/>
	  <nsName ns="http://purl.oclc.org/dsdl/svrl"/>
	</except>
      </anyName>
      <!--      <ref name="Anything"/> -->
      <text/>
    </element>
  </zeroOrMore>
</define>
</div>

<div html:id="anything"> 
<html:h3>Element anything</html:h3> 
<html:p>Any element in any namespace (including svrl ns or null namespace)</html:p> 
<define name="Anything">
  <zeroOrMore>
    <choice>
      <element>
	<anyName/>
	<ref name="Anything"/>
      </element>
      <attribute>
	<anyName/>
      </attribute>
      <text/>
    </choice>
  </zeroOrMore>
</define>
</div>




<div html:id="foreign-empty"> 
  <html:h3>An empty element with foreign attributes</html:h3> 
  <html:p>An element not in the Schematron namespace which is empty and may contain attributes </html:p> 
  <define name="Foreign-empty">
    <ref name="Foreign-attributes"/>
  </define>
</div>
 


<div html:id="foreign-attributes.att"> 
<html:h3>Foreign attributes </html:h3>
<html:p>attributes of elements in a namespace other than the
Schematron namespace. </html:p> 
  <define name="Foreign-attributes">
    <zeroOrMore>
      <attribute>
        <anyName>
          <except>
            <nsName ns=""/>
            <nsName ns="http://www.w3.org/XML/1998/namespace"/>
          </except>
        </anyName>
      </attribute>
    </zeroOrMore>
  </define>
</div>




<div html:id="rich.att"> 
<html:h3>Rich. </html:h3> 
<html:p>A set of optional attributes which may be used to decorate some elements </html:p> 
  <define name="Rich">
    <optional>
      <attribute name="icon">
        <ref name="UriValue"/>
      </attribute>
    </optional>
    <optional>
      <attribute name="see">
        <ref name="UriValue"/>
      </attribute>
    </optional>
    <optional>
      <attribute name="fpi">
        <ref name="FpiValue"/>
      </attribute>
    </optional>
    <optional>
      <attribute name="xml:lang">
        <ref name="LangValue"/>
      </attribute>
    </optional>
    <optional>
      <attribute name="xml:space">
        <choice>
          <value>preserve</value>
          <value>default</value>
        </choice>
      </attribute>
    </optional>
  </define>
</div>


<div html:id="linkable.att"> 
<html:h3>linkable attribute </html:h3>
<html:p>Optional attributes (role and subject). If the subject is
present, the role attribute labels the arc between the context node
and any nodes which match the subject value (an xpath expression).
</html:p>
  <define name="Linkable">
    <optional>
      <attribute name="role">
        <ref name="RoleValue"/>
      </attribute>
    </optional>
    <optional>
      <attribute name="subject">
        <ref name="PathValue"/>
      </attribute>
    </optional>
  </define>
</div>




  <!-- Data types -->

<div html:id="roleValue.dat"> 
<html:h3>Datatype  roleValue</html:h3> 
<html:p>The role attribute allows you to label the subject and subject
nodes of assertions with simple labels. You could also see it as
labelling the arcs between context subject and the arc subjects. For
example, if generating RDF: see <html:a
href="http://lists.xml.org/archives/xml-dev/200308/msg00541.html">xml-dev
archive</html:a></html:p>
<html:p>For example, imagine you had a document containing gene sequences. You
could use the role attribute to label the junk DNA parts.</html:p>
<html:p>So the role could be what role the subject plays in the document, but is
could be what role the subject plays in the pattern, or what role the rule
plays in the pattern.</html:p>
<html:p>The role attribute is used, therefore, like a kind of type binding, but
instead of binding the node to a type name, it is bound to (one or more)
arbitrary names.</html:p> 
  <define name="RoleValue">
    <data type="string" datatypeLibrary=""/>
  </define>
</div>


<div html:id="uriValue.dat"> 
<html:h3>Datatype uriValue </html:h3> 
<html:p>A URI, used as the value of an attribute to specify, for
example, an inclusion, an icon file, or simply a namespace URI
</html:p>
  <define name="UriValue">
    <data type="anyURI"/>
  </define>
</div>

<div html:id="pathValue.dat"> 
<html:h3>Datatype pathValue </html:h3> 
<html:p>An xpath expression returning a node value or name (dependent
on context) </html:p>
  <define name="PathValue">
    <data type="string" datatypeLibrary=""/>
  </define>
</div>


<div html:id="fpiValue.dat"> 
<html:h3>Datatype  fpiValue </html:h3> 
<html:p>A formal public identifier for containing element (schema, assert, report etc) </html:p> 
  <define name="FpiValue">
    <data type="string" datatypeLibrary=""/>
  </define>
</div>

<div html:id="exprValue.dat"> 
<html:h3>Datatype exprValue </html:h3> 
<html:p>An xpath expression returning a boolean value. See <html:a
href="#assert">assert</html:a> and <html:a
href="#report">report</html:a> which both use the test
attribute. </html:p>
  <define name="ExprValue">
    <data type="string" datatypeLibrary=""/>
  </define>
</div>

<div html:id="langValue.dat"> 
<html:h3>Datatype  langValue</html:h3> 
<html:p>The value assigned to an xml:lang attribute. Normally used to
identify the language used in the containing element and its children. </html:p>
  <define name="LangValue">
    <data type="language"/>
  </define>
</div>

</grammar>


<!-- 

<div html:id=""> 
<html:h3>Element </html:h3> 
<html:p> </html:p> 

</div>


<div html:id=""> 
<html:h3>Element </html:h3> 
<html:p> </html:p> 
<define name=""> 
  <element name=""> 
    <mixed>
      <zeroOrMore>
	<choice>
	  <ref name=""/>
	</choice>
      </zeroOrMore>
    </mixed>
</element> 
</define> 
</div>


 -->

