<?xml version="1.0" encoding="us-ascii"?>
<!DOCTYPE document [
<!ENTITY endash "&#x2013;">
<!ENTITY emdash "&#x2014;">
<!ENTITY hellip "&#x2026;">
<!ENTITY rsquo "&#x2019;">
<!ENTITY hyphen "-">
<!ENTITY rng "ISO 19757-2:2003">
]>
<?xml-stylesheet type="text/css" href="is.css" ?>
<?oxygen RNGSchema="is.rnc" type="compact"?>
<document>
    <head>
        <organization>ISO/IEC</organization>
        <document-type>International Standard</document-type>
        <stage>committee</stage>
        <secretariat>SCC</secretariat>
        <tc-number>1</tc-number>
        <tc-name>Information Technology</tc-name>
        <sc-number>34</sc-number>
        <sc-name>Document Description and Processing Languages</sc-name>
        <wg-number>1</wg-number>
        <document-number>19757</document-number>
        <part-number>9</part-number>
        <document-language>E</document-language>
        <date>2006-02-06</date>
       <title>
            <main>Document Schema Definition Languages (DSDL)</main>
            <complementary>Namespace- and datatype-aware DTDs</complementary>
        </title>
    </head>
    <foreword>
        <part-list>
            <part>
                <number>1</number>
                <title>Overview</title>
            </part>
            <part>
                <number>2</number>
                <title>Regular grammar&hyphen;based validation &emdash; RELAX NG</title>
            </part>
            <part>
                <number>3</number>
                <title>Rule-based validation &emdash; Schematron</title>
            </part>
            <part>
                <number>4</number>
                <title>Namespace-based validation dispatching language &emdash; NVDL</title>
            </part>
            <part>
                <number>5</number>
                <title>Datatype Library Language &emdash; DTLL</title>
            </part>
            <part>
                <number>6</number>
                <title>Path-based integrity constraints</title>
            </part>
            <part>
                <number>7</number>
                <title>Character Reportoire Description Language &emdash; CRDL</title>
            </part>
            <part>
                <number>8</number>
                <title>Document Schema Renaming Language &emdash; DSRL</title>
            </part>
            <part>
                <number>9</number>
                <title>Datatype&hyphen; and namespace&hyphen;aware DTDs</title>
            </part>
            <part>
                <number>10</number>
                <title>Validation Management</title>
            </part>
        </part-list>
    </foreword>
    <introduction>
        <p>The language of Document Type Definitions (DTDs) was the original schema language defined by <xref to="xml-rec"/> and was closely based upon the DTD language defined by <xref to="sgml"/>. For a variety of reasons, both technical and economic, many users of XML for document-centric applications, especially among those who were previously (and in some cases continue to be) users of SGML, still favour the use of DTD language for grammar-based schema definition in such applications. </p>
        <p>It is important to provide users that have made a significant investment in DTDs with a migration path that will enable them to adopt DSDL without having to translate all their existing DTDs to a different schema language, especially as this would oblige them to replace all systems that only work with DTDs, with all the expense and organizational upheavals thereby entailed. A sensible migration path should enable such users to continue to use DTDs for as much of the document validation process as can reasonably be managed, but also enable them to reap the benefits of using those parts of DSDL that most obviously complement and extend the use of DTDs for validation purposes.</p>
        <p>It is equally important that the migration path should enable users to continue to use legacy systems that are incapable of using any kind of extension to the DTD language, while at the same time introducing new systems that are equipped to use such extensions. The method of extension must therefore be such that DTDs with extended functionality are valid XML DTDs in accordance with <xref to="xml-rec"/>. It should remain possible to validate an instance <i>that does not make any use of the extended functionality</i> against a DTD that contains the extended functionality, using legacy system tools, and achieve the same result as would be achieved if the DTD did not contain the extended functionality.</p>
        <p>The most significant validation tasks that cannot be performed using a DTD alone are:</p>
        <ul>
            <li><p>validation of names with respect to namespaces</p></li>
            <li><p>validation of data content and attribute values with respect to datatypes</p></li>
            <li><p>rules-based validation</p></li>
        </ul>
        <p>Of these three, the last is made possible by implementation of Part 3 of DSDL. The first two tasks are currently only possible if Part 2 of DSDL is implemented, but existing DTD users are unlikely to wish to maintain parallel RELAX NG and DTD schemas for each application simply as a means of supporting the use of namespaces and datatypes.</p>
        <p>For these reasons this International Standard addresses the extension of DTDs to support the use of namespaces and datatypes.</p>
    </introduction>
    <scope>
        <p>This International Standard defines a language that is designed to extend the functionality of an XML DTD to include:</p>
        <ul>
            <li><p>specifying one or more namespaces to which some or all of the element and attribute names in a DTD belong</p></li>
            <li><p>constraining elements with content model 'ANY' to contain elements whose names belong to one or more specified namespaces</p></li>
            <li><p>specifying datatypes for elements that contain data content and for attribute values.</p></li>
        </ul>
        <p>Two alternative syntax bindings for this language are defined. The first syntax binding uses XML processing instructions and is designed to enable declarations in this language to be embedded within an XML DTD without invalidating the DTD or altering its interpretation so far as legacy DTD parsers are concerned. This first syntax also provides a means of associating a DTD with an external subset containing declarations in either syntax. This syntax is defined in <xref to="pi-syntax"/> using the modified BNF syntax notation used in <xref to="xml-rec"/>.</p>
        <p>The second syntax binding uses an XML document syntax and is defined in <xref to="xml-syntax"/>. The syntax rules are defined by a schema that conforms to the RELAX NG Compact Syntax defined in Part 2 of this standard. This syntax is designed to enable declarations in this language to be expressed almost entirely in XML (in this case one XML processing instruction needs to be inserted in the DTD), to facilitate implementation using existing XML tools, either as a namespace-qualified fragment embedded within an XML instance or as a separate XML document.</p>
    </scope>
    <normative-references>
        <referenced-document id="sgml">
            <abbrev>SGML</abbrev>
            <title>ISO 8879:1986 Information Processing - Text and Office Systems - Standard Generalized Markup Language (SGML)</title>
            <url>http://www.iso.org/</url>
        </referenced-document>
        <referenced-document id="xml-rec">
            <abbrev>W3C XML</abbrev>
            <title>Extensible Markup Language (XML) 1.0 (Third Edition)</title>
            <field>W3C Recommendation</field>
            <field>30 October 2003</field>
            <url>http://www.w3.org/TR/2003/PER-xml-20031030/</url>
        </referenced-document>
        <referenced-document id="xml-names">
            <abbrev>W3C XML-Names</abbrev>
            <title>Namespaces in XML</title>
            <field>W3C Recommendation</field>
            <field>14 January 1999</field>
            <url>http://www.w3.org/TR/1999/REC-xml-names-19990114/</url>
        </referenced-document>
        <referenced-document id="dsdl-2">
            <abbrev>RELAX NG</abbrev>
            <title>Grammar-based schema language (RELAX NG)</title>
            <field>ISO/IEC 19757 Part 2</field>
            <url>http://www.dsdl.org/</url>
        </referenced-document>
        <referenced-document id="dsdl-5">
            <abbrev>DTLL</abbrev>
            <title>Datatype Library Language</title>
            <field>ISO/IEC 19757 Part 5</field>
            <url>http://www.dsdl.org/</url>
        </referenced-document>
        <referenced-document id="iri">
            <abbrev>IRI</abbrev>
            <title>Internationalized Resource Identifiers (IRI)</title>
            <field>IETF RFC 3987</field>
            <url>http://www.ietf.org/rfc/rfc3987</url>
        </referenced-document>
    </normative-references>
    <terms-and-definitions>
        <term-and-definition>
            <term>external declarations subset</term>
            <definition>An XML resource containing a set of DTD extension declarations either in XML processing instruction syntax or in XML document syntax in accordance with this Part of DSDL.</definition>
        </term-and-definition>
        <term-and-definition>
            <term>qualified datatype name</term>
            <definition>A datatype name containing a qualifying prefix and a local part separated by a colon ':', the prefix of which is bound to the IRI of a datatype library by a datatype library prefix binding declaration as described in this standard.</definition>
        </term-and-definition>
        <term-and-definition>
            <term>unqualified datatype name</term>
            <definition>A datatype name does not contain a colon ':' and therefore contains only a local part.</definition>
        </term-and-definition>
    </terms-and-definitions>
    <clause id="pi-syntax">
        <title>DTD extension declarations using XML processing instruction syntax</title>
         <p>The following set of syntax productions define how namespace and datatype declarations expressed in accordance with this standard may be represented as XML processing instructions. Syntax productions for <i>pio</i>, <i>pic</i>, <i>name-token-group</i>, <i>NCName</i>, <i>URI</i>, <i>lit</i>, <i>lita</i> and <i>s</i> are given in <xref to="xml-rec"/>.</p>
        <p>DTD-extension-processing-instruction ::= <i>pio</i> "DSDL-9" <i>s</i> (<i>namespace-prefix-binding-declaration</i> | <i>namespace-name-binding-declaration</i> | <i>wildcard-namespace-qualifier-declaration</i> | <i>default-datatype-library-declaration</i> | <i>datatype-library-prefix-binding-declaration</i> | <i>datatype-binding-declaration</i> | <i>external-declarations-subset-locator</i>) <i>pic</i></p>
        <p>namespace-prefix-binding-declaration ::= "namespace-prefix-binding" <i>s</i> "namespace-iri=" <i>IRI-literal</i> <i>s</i> "prefix=" <i>prefix-literal</i></p>
        <p>namespace-name-binding-declaration ::= "namespace-name-binding" <i>s</i> "namespace-iri=" <i>IRI-literal</i> <i>s</i> "applies-to-element=" <i>name-locator-literal</i></p>
        <p>wildcard-namespace-qualifier-declaration ::= "wildcard-namespace-qualifier" <i>s</i> "namespace-iri=" <i>wildcard-namespace-literal</i> <i>s</i> "applies-to-element=" <i>name-locator-literal</i></p>
        <p>wildcard-namespace-literal ::= ((<i>lit</i> <i>wildcard-namespace-sequence</i> <i>lit</i>) | (<i>lita</i> <i>wildcard-namespace-sequence</i> <i>lita</i>))</p>
        <p>wildcard-namespace-sequence ::= <i>IRI</i> (<i>s</i> <i>IRI</i>)*</p>
        <p>name-locator-literal ::= ((<i>lit</i> <i>name-locator-sequence</i> <i>lit</i>) | (<i>lita</i> <i>name-locator-sequence</i> <i>lita</i>))</p>
        <p>name-locator-sequence ::= (<i>s</i>)? (<i>name-token-group</i> | <i>any-name</i>) (<i>s</i>)? </p>
        <p>any-name ::= "#any"</p>
        <p>default-datatype-library-declaration ::= "default-datatype-library-iri=" <i>IRI-literal</i></p>
        <p>datatype-library-prefix-binding-declaration ::= "datatype-library-prefix-binding" <i>s</i> "datatype-library-iri=" <i>IRI-literal</i> <i>s</i> "prefix=" <i>prefix-literal</i></p>
        <p>datatype-binding-declaration ::= "datatype-binding" <i>s</i> "datatype-name=" <i>datatype-literal</i> <i>s</i> (("applies-to-element=" <i>name-locator-literal</i>) | ("applies-to-attribute=" <i>name-locator-literal</i> "of-element" <i>name-locator-literal</i> ))</p>
        <p>datatype-name ::= <i>NCName</i></p>
        <p>datatype-qname ::= <i>prefix</i> ":" <i>datatype-name</i></p>
        <p>datatype-literal ::= ((<i>lit</i> (<i>datatype-name</i> | <i>datatype-qname</i>) <i>lit</i>) | (<i>lita</i> (<i>datatype-name</i> | <i>datatype-qname</i>) <i>lita</i>))</p>
        <p>prefix-literal ::= ((<i>lit</i> <i>prefix</i> <i>lit</i>) | (<i>lita</i> <i>prefix</i> <i>lita</i>))</p>
        <p>prefix ::= <i>NCName</i></p>
        <p>external-declarations-subset-locator ::= "external-declarations-subset" <i>s</i> "location=" <i>IRI-literal</i> <i>s</i> "syntax=" ((<i>lit</i> ("pi" | "xml") <i>lit</i>) | (<i>lita</i> ("pi" | "xml") <i>lita</i>))</p>
        <p>IRI-literal ::= ((<i>lit</i> <i>IRI</i> <i>lit</i>) | (<i>lita</i> <i>IRI</i> <i>lita</i>))</p>
        <p>IRI ::= <i>URI</i></p>
        <p>NOTE - An <i>IRI</i> must be a <i>URI</i> that conforms to <xref to="iri"/>.</p>
    </clause>
    <clause id="xml-syntax">
        <title>DTD extension declarations using XML document syntax</title>
        <p>The following schema in RELAX NG Compact Syntax specifies how a set of namespace and datatype declarations expressed in accordance with this standard may be represented as an XML document.</p>
        <pre>datatypes xsd = "http://www.w3.org/2001/XMLSchema-datatypes"
default namespace = "http://dsdl.org/dsdl-9"

start = document

document = element dtd-extension { head, body }

head = (element applies-to-dtd {public | system} )*

public = element public {text}, system?

system = element system {xsd:anyURI}

body = ( namespace-prefix-binding |  
         namespace-name-binding | 
         wildcard-namespace-qualifier | 
         default-datatype-library | 
         datatype-library-prefix-binding | 
         datatype-binding )+

namespace-prefix-binding = element namespace-prefix-binding 
                           { namespace-iri, prefix }

namespace-name-binding = element namespace-name-binding 
                         { namespace-iri, applies-to-element}

applies-to-element = element applies-to-element 
                     { (name+ | any-name) }

applies-to-attribute = element applies-to-attribute 
                       { (name+ | any-name), of-element-names }

of-element-names = element of-element-names 
                   { name+ | any-name }

name = element name {xsd:NMTOKEN}

any-name = element any {empty}

wildcard-namespace-qualifier = element wildcard-namespace-qualifier 
                               { (namespace-iri+, applies-to-element) }

default-datatype-library = element default-datatype-library 
                           { library-iri }

datatype-library-prefix-binding = element datatype-library-prefix-binding 
                                  { (library-iri, prefix) }

library-iri = element library-iri {xsd:anyURI}

datatype-binding = element datatype-binding 
                   { name, (applies-to-element | applies-to-attribute) }

namespace-iri = element namespace-iri {xsd:anyURI}

prefix = element prefix {xsd:NMTOKEN}       </pre>
    </clause>
    <clause id="declarations-location">
        <title>Location and ordering of DTD extension declarations</title>
        <p>DTD extension declarations in processing instruction syntax must be located in one or more of the following locations:</p>
        <ul>
            <li><p>a DTD's external subset, </p></li>
            <li><p>the local subset of a DTD declaration, or</p></li>
            <li><p>an external declarations subset whose location IRI is specified by declaring an external declarations subset locator within the DTD's external or local subset.</p></li>
        </ul>
        <p>DTD extension declarations in XML document syntax must be located as an external declarations subset whose location IRI is specified by declaring an external declarations subset locator within the DTD's external or local subset. </p>
        <p>The ordering of all the DTD extension declarations that are associated with a DTD is the same ordering that would be obtained by substituting all extension declarations in XML document syntax with equivalent declarations in processing instruction syntax and by treating each external declarations subset were an external parameter entity of the DTD and its corresponding locator declaration were a reference to that external parameter entity.</p>
    </clause>
    <clause id="namespace">
        <title>Inclusion of namespace information in DTDs</title>
        <p>A namespace IRI may be associated with the names of any elements that are declared in a DTD, including both qualified and unqualified names. A namespace IRI may also be declared as a constraint on the content of an element whose declared content model is "ANY".</p>
        <clause id="qualified-names">
            <title>Associating namespaces with qualified names</title>
            <p>A namespace IRI may be associated with specified element names or attribute names that include qualifying prefixes, by declaring a corresponding namespace prefix binding.</p>
            <p>Each qualifying prefix may only be bound once to a namespace IRI. If two or more namespace prefix binding declarations specify the same qualifying prefix, the second and subsequent declarations are ignored.</p>
        </clause>
        <clause id="unqualified-names">
            <title>Associating namespaces with unqualified names</title>
            <p>A namespace IRI may be associated with specified element names that do not include qualifying prefixes, by declaring a corresponding namespace name binding.</p>
            <p>An unqualified name has no namespace unless a namespace name binding is declared that applies to this name.</p>
            <p>A namespace IRI may be associated with any element name for which a namespace name binding has not previously been declared, by declaring a namespace name binding in which the "any name" indicator is included instead of a list of names. Any subsequent namespace name binding declarations are ignored. </p>
            <p>Each unqualified name may only be bound once to a namespace IRI. If two or more namespace name binding declarations explicitly specify the same name, the second and subsequent declarations are ignored. </p>
        </clause>
        <clause id="model-any">
            <title>Associating namespace constraints with elements with content model "ANY"</title>
            <p>A namespace IRI may be associated with the content of an element whose content model is declared to be "ANY", by defining a wildcard namespace qualifier declaration for that element. A namespace IRI may only be specified in a wildcard namespace qualifier declaration if it occurs either in a namespace prefix binding declaration or in a namespace name binding declaration for the same DTD.</p>
            <p>A wildcard namespace qualifier declaration may only associate a namespace IRI with the content of elements whose content model is "ANY". The name of any element whose content model is not "ANY" will be ignored. </p>
        </clause>
    </clause>
    <clause id="datatype">
        <title>Inclusion of datatype information in DTDs</title>
        <p>A datatype may be associated with a specified element or attribute, by declaring a datatype name together with the name of the element or attribute to which it applies. </p>
        <p>Every datatype name must be associated with a declared datatype library. Unqualified datatype names are associated with a default datatype library, while qualified datatype names are associated with declared datatype libraries by declaring a binding between the qualifying prefix and the associated datatype library.</p>
        <p>The IRI specified in either a datatype library prefix binding declaration or a default datatype library declaration must identify a datatype library, for example a library that conforms to Part 5 of this International Standard (DTLL).</p>
        <p>If two or more datatype declarations apply to the same element content or attribute value, the second and subsequent declarations are ignored.</p>
        <clause id="qualified-datatype-names">
            <title>Associating datatype libraries with qualified datatype names</title>
            <p>If a specified datatype name includes a qualifying prefix, a corresponding datatype library prefix binding must be declared.</p>
            <p>Each qualifying prefix may only be bound once to a datatype library. If two or more datatype library prefix binding declarations specify the same prefix, the second and subsequent declarations are ignored.</p>
        </clause>
        <clause id="unqualified-datatype-names">
            <title>Associating datatype libraries with unqualified datatype names</title>
            <p>If a specified datatype name has no qualifying prefix, a default datatype library must be declared.</p>
            <p>If two or more default datatype libraries are declared, the second and subsequent default datatype library declarations are ignored.</p>
        </clause>
    </clause>
    <clause>
        <title>Validity of DTDs and instances that include namespace or datatype information in accordance with this Part of DSDL</title>
        <clause>
            <title>Validity of DTDs</title>
            <p>If a DTD is valid according to a legacy parser, it must be valid according to a DSDL-9-aware parser, regardless of whether or not it contains namespace or datatype information in accordance with this Part of DSDL.</p>
            <p>Similarly, if a DTD is invalid according to a legacy parser, it must be invalid according to a DSDL-9-aware parser, which must report the same errors as a legacy parser.</p>
            <p>If a DTD contains namespace or datatype information that is intended to be expressed in accordance with this Part of DSDL, but contains errors of any kind, a DSDL-9-aware parser may report these errors in warning messages but shall not report the DTD as being invalid.</p>
        </clause>
        <clause>
            <title>Validity of instances</title>
            <p>If an instance is valid according to a legacy parser and its DTD does not contain namespace or datatype information in accordance with this Part of DSDL, it must be valid according to a DSDL-9-aware parser.</p>
            <p>Similarly, if an instance is invalid according to a legacy parser and its DTD does not contain namespace or datatype information in accordance with this Part of DSDL, it must be invalid according to a DSDL-9-aware parser, which must report the same errors as a legacy parser.</p>
        </clause>
    </clause>
    <annex id="examples" normative="false">
        <title>Example declarations</title>
        <clause id="pi-examples">
            <title>Examples in XML processing instruction syntax</title>
            <p>The following example demonstrates the use of the XML processing instruction syntax to include declarations in a DTD in accordance with this Part of DSDL.</p>
            <example>
                <pre>
                    <![CDATA[
<?DSDL-9 namespace-prefix-binding namespace-iri="http://dsdl.org/" prefix="dsdl"?>
<?DSDL-9 namespace-prefix-binding namespace-iri="http://www.w3.org/1999/xhtml" prefix="html"?>
<?DSDL-9 namespace-name-binding namespace-iri="http://www.w3.org/1999/xhtml" 
         applies-to-element="table thead tbody tfoot col colgroup th tr td"?>
<?DSDL-9 wildcard-namespace-qualifier namespace-iri="http://www.w3.org/1999/xhtml" 
         applies-to-element="web-documentation"?>
<?DSDL-9 datatype-library-prefix-binding library-iri="http://www.w3.org/2001/XMLSchema-datatypes" 
         prefix="xs"?>
<?DSDL-9 datatype-binding datatype-name="xs:anyURI" applies-to-attribute="href" of-element="#any"?>
<?DSDL-9 datatype-binding datatype-name="xs:string" applies-to-element="foo"?>
                    ]]>
                </pre>
            </example>
            <p>The following example demonstrations the use of a single XML processing instruction to associate a DTD with an external set of declarations in XML document syntax in accordance with Clause <Xref to="xml-syntax"/> of this Part of DSDL.</p>
            <example>
                <pre>
                    <![CDATA[
<?DSDL-9 external-declarations-subset location="http://www.example.com" syntax="xml"?>
                    ]]>
                </pre>
            </example>
        </clause>
        <clause id="xml-examples">
            <title>Example in XML document syntax</title>
            <p>The following example contains the same declarations as in the preceding clause, but in XML syntax.</p>
            <example>
                <pre>
<![CDATA[
<?xml version="1.0" encoding="UTF-8"?>
<dtd-extension xmlns="http://dsdl.org/dsdl-9">
     <namespace-prefix-binding>
          <namespace-iri>http://dsdl.org/</namespace-iri>
          <prefix>dsdl</prefix>
     </namespace-prefix-binding>
     <namespace-prefix-binding>
          <namespace-iri>http://www.w3.org/1999/xhtml</namespace-iri>
          <prefix>html</prefix>
     </namespace-prefix-binding>
     <namespace-name-binding>
          <namespace-iri>http://www.w3.org/1999/xhtml</namespace-iri>
          <applies-to-element>
               <name>table</name>
               <name>thead</name>
               <name>tbody</name>
               <name>tfoot</name>
               <name>col</name>
               <name>colgroup</name>
               <name>th</name>
               <name>tr</name>
               <name>td</name>
          </applies-to-element>
     </namespace-name-binding>
     <wildcard-namespace-qualifier>
          <namespace-iri>http://www.w3.org/1999/xhtml</namespace-iri>
          <applies-to-element>
               <name>web-documentation</name>
          </applies-to-element>
     </wildcard-namespace-qualifier>
     <datatype-library-prefix-binding>
          <library-iri>http://www.w3.org/2001/XMLSchema-datatypes</library-iri>
          <prefix>xs</prefix>
     </datatype-library-prefix-binding>
     <datatype-binding>
          <name>xs:anyURI</name>
          <applies-to-attribute>
               <name>href</name>
               <of-element-names>
                    <any/>
               </of-element-names>
          </applies-to-attribute>
     </datatype-binding>
     <datatype-binding>
          <name>xs:string</name>
          <applies-to-element>
               <name>foo</name>
          </applies-to-element>
     </datatype-binding>
</dtd-extension>
]]>
                </pre>
            </example>
       </clause>
    </annex>
</document>

