⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 xmlschema.rng

📁 xml 组建工程 不多说说 很都功能 就是懒得整理
💻 RNG
📖 第 1 页 / 共 4 页
字号:
<?xml version="1.0"?>
<grammar xmlns="http://relaxng.org/ns/structure/1.0"
      datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes"
      ns="http://www.w3.org/2001/XMLSchema"
      xmlns:xs="http://www.w3.org/2001/XMLSchema"
      xmlns:doc="http://www.jenitennison.com/doc">

<doc:p>
  RELAX NG schema for XML Schema by <doc:link 
  href="mailto:mail@jenitennison.com">Jeni Tennison</doc:link>. Based on 
  <doc:link href="http://www.w3.org/TR/2001/REC-xmlschema-1-20010502/">XML 
  Schema Part I: Structures Recommendation</doc:link> and <doc:link 
  href="http://www.w3.org/TR/2001/REC-xmlschema-2-20010502/">XML Schema Part 
  II: Datatypes</doc:link>.
</doc:p>
<doc:changes date="2001-11-24">
  <doc:p>
    Amended to comply with 10 August 2001 Tutorial.
  </doc:p>
  <doc:change>Removed key attributes.</doc:change>
  <doc:change>Replaced not element with except elements.</doc:change>
  <doc:change>
    Replaced multiple consecutive optional attributes to use the 
    zeroOrMore/choice pattern.
  </doc:change>
  <doc:change>
    Removed interleave elements inside list elements (which are no longer 
    permitted).
  </doc:change>
</doc:changes>

<define name="openAttrs">
  <doc:p>
    This allows any number of attributes that are not in the XML Schema 
    namespace or are in no namespace.  This is somewhat more complicated than 
    the XML Schema anyAttribute equivalent. 
  </doc:p>
  <zeroOrMore>
    <attribute>
      <anyName>
        <except>
          <nsName />
          <nsName ns="" />
          <name>xml:lang</name>
        </except>
      </anyName>
      <text />
    </attribute>
  </zeroOrMore>
</define>

<define name="annotated">
  <doc:p>
    This allows any number of attributes that are not in the XML Schema 
    namespace or are in no namespace, an optional id attribute of type ID, 
    and an optional annotation element.  This is used as the basis for many 
    element content models.
  </doc:p>
  <ref name="openAttrs" />
  <optional>
    <attribute name="id">
      <data type="ID" />
    </attribute>
  </optional>
  <optional>
    <ref name="annotation" />
  </optional>
</define>

<define name="schemaTop">
  <doc:p>
    This gives the content model of the top level of the schema.
  </doc:p>
  <choice>
    <ref name="redefinable" />
    <ref name="topLevelElement" />
    <ref name="topLevelAttribute" />
    <ref name="notation" />
  </choice>
</define>

<define name="redefinable">
  <doc:p>
    This gives the components that can be redefined within the redefine 
    element.  They also occur at the top level of the schema.
  </doc:p>
  <choice>
    <ref name="topLevelSimpleType" />
    <ref name="topLevelComplexType" />
    <ref name="namedGroup" />
    <ref name="namedAttributeGroup" />
  </choice>
</define>

<define name="formChoice">
  <doc:p>
    This gives the values for the various form attributes: 
    elementFormDefault and attributeFormDefault on the schema element, and
    the form attributes on the element and attribute elements.
  </doc:p>
  <choice>
    <value>qualified</value>
    <value>unqualified</value>
  </choice>
</define>

<define name="reducedDerivationControl">
  <doc:p>
    This gives the values that can be taken in the lists used to control
    derivation by extension or restriction (this is 'reduced' derivation
    because some derivation can involve substitution).  This RELAX NG schema, 
    like the XML Schema Recommendation here, allows the keywords 'extension' and 
    'restriction' to be repeated any number of times.
  </doc:p>
  <list>
    <zeroOrMore>
      <choice>
        <value>extension</value>
        <value>restriction</value>
      </choice>
    </zeroOrMore>
  </list>
</define>

<define name="derivationSet">
  <doc:p>
    This specifies the possible values for attributes that control derivation.
  </doc:p>
  <choice>
    <value>#all</value>
    <ref name="reducedDerivationControl" />
  </choice>
</define>

<start>
  <doc:p>
    This is the beginning point for the schema, and defines the schema 
    element.
  </doc:p>
  <element name="schema" 
        doc:href="http://www.w3.org/TR/xmlschema-1/#element-schema">
    <ref name="openAttrs" />
    <zeroOrMore>
      <choice>
        <attribute name="version">
          <data type="token" />
        </attribute>
        <attribute name="finalDefault">
          <ref name="derivationSet" />
        </attribute>
        <attribute name="blockDefault">
          <ref name="blockSet" />
        </attribute>
        <attribute name="attributeFormDefault">
          <ref name="formChoice" />
        </attribute>
        <attribute name="elementFormDefault">
          <ref name="formChoice" />
        </attribute>
        <attribute name="id">
          <data type="ID" />
        </attribute>
        <attribute name="xml:lang">
          <data type="language" />
        </attribute>
      </choice>
    </zeroOrMore>
    <choice>
      <group>
        <doc:p>
          If a targetNamespace attribute is specified on the schema 
          element, then the namespace attribute on the import elements 
          that it contains are optional.
        </doc:p>
        <attribute name="targetNamespace">
          <data type="anyURI" />
        </attribute>
        <zeroOrMore>
          <choice>
            <ref name="include" />
            <ref name="importOptionalNamespace" />
            <ref name="redefine" />
            <ref name="annotation" />
          </choice>
        </zeroOrMore>
      </group>
      <zeroOrMore>
        <doc:p>
          If a targetNamespace attribute is not specified on the schema 
          element, then the import elements that it contains must specify 
          a namespace.
        </doc:p>
        <choice>
          <ref name="include" />
          <ref name="importRequiredNamespace" />
          <ref name="redefine" />
          <ref name="annotation" />
        </choice>
      </zeroOrMore>
    </choice>
    <zeroOrMore>
      <ref name="schemaTop" />
      <zeroOrMore>
        <ref name="annotation" />
      </zeroOrMore>
    </zeroOrMore>
  </element>
</start>

<define name="allNNI">
  <doc:p>
    This gives the value type for the maxOccurs attribute, which may be a 
    non-negative number or the keyword 'unbounded'.
  </doc:p>
  <choice>
    <data type="nonNegativeInteger" />
    <value type="token">unbounded</value>
  </choice>
</define>

<define name="occurs">
  <doc:p>
    This specifies the occurs attributes, minOccurs and maxOccurs, as they 
    are normally used.
  </doc:p>
  <zeroOrMore>
    <choice>
      <attribute name="minOccurs">
        <data type="nonNegativeInteger" />
      </attribute>
      <attribute name="maxOccurs">
        <ref name="allNNI" />
      </attribute>
    </choice>
  </zeroOrMore>
</define>

<define name="typeDefParticle">
  <doc:p>
    This gives the possible content of complex types.
  </doc:p>
  <choice>
    <ref name="groupRef" />
    <ref name="all" />
    <ref name="choice" />
    <ref name="sequence" />
  </choice>
</define>

<define name="nestedParticle">
  <doc:p>
    This gives the particles that can make up a model group.
  </doc:p>
  <choice>
    <ref name="localElement" />
    <ref name="groupRef" />
    <ref name="choice" />
    <ref name="sequence" />
    <ref name="any" />
  </choice>
</define>

<define name="fixedOrDefault">
  <doc:p>
    This specifies the relationship between fixed and default attributes on 
    element and attribute elements - if one is present, then the other cannot 
    be.  This is a constraint that cannot be specified using XML Schema.
  </doc:p>
  <choice>
    <empty />
    <attribute name="fixed" />
    <attribute name="default" />
  </choice>
</define>

<define name="attributeType">
  <doc:p>
    This specifies the relationship between the type attribute and the 
    simpleType element child of attribute elements - if one is present, then 
    the other cannot be, although it is possible for neither to be allowed.
  </doc:p>
  <choice>
    <empty />
    <attribute name="type">
      <data type="QName" />
    </attribute>
    <ref name="localSimpleType" />
  </choice>
</define>

<define name="localAttribute">
  <doc:p>
    This describes attribute elements when used in a local context.  They 
    have an optional use attribute, possibly a fixed or default attribute, 
    and then can either have a ref attribute (referring to a top-level 
    attribute) or a name attribute with an optional form attribute and 
    specifying an attribute type.
  </doc:p>
  <element name="attribute" 
        doc:href="http://www.w3.org/TR/xmlschema-1/#element-attribute">
    <ref name="annotated" />
    <optional>
      <attribute name="use">
        <choice>
          <value type="token">optional</value>
          <value type="token">prohibited</value>
          <value type="token">required</value>
        </choice>
      </attribute>
    </optional>
    <ref name="fixedOrDefault" />
    <choice>
      <attribute name="ref">
        <data type="QName" />
      </attribute>
      <group>
        <attribute name="name">
          <data type="NCName" />
        </attribute>
        <optional>
          <attribute name="form">
            <ref name="formChoice" />
          </attribute>
        </optional>        
        <ref name="attributeType" />
      </group>
    </choice>
  </element>
</define>

<define name="topLevelAttribute">
  <doc:p>
    This describes attribute elements when used at the top level of the 
    schema.  They must have a name, may have a fixed or default attribute, 
    and specify their type through a type attribute or child simpleType 
    element.  The name attribute of each attribute element that appears at 
    the top level of the schema is unique.
  </doc:p>
  <element name="attribute"
        doc:href="http://www.w3.org/TR/xmlschema-1/#element-attribute">
    <ref name="annotated" />
    <attribute name="name">
      <data type="NCName" />
    </attribute>
    <ref name="fixedOrDefault" />
    <ref name="attributeType" />
  </element>
</define>

<define name="attrDecls">
  <doc:p>
    This gives the model group for specifying the attributes in a complex 
    type, an extension or restriction.
  </doc:p>
  <zeroOrMore>
    <choice>
      <ref name="localAttribute" />
      <ref name="attributeGroupRef" />
    </choice>
  </zeroOrMore>
  <optional>
    <ref name="anyAttribute" />
  </optional>
</define>

<define name="anyAttribute">
  <doc:p>
    This specifies the anyAttribute wildcard.
  </doc:p>
  <element name="anyAttribute"
        doc:href="http://www.w3.org/TR/xmlschema-1/#element-anyAttribute">
    <ref name="wildcard" />
  </element>
</define>

<define name="complexTypeModel">
  <doc:p>
    This specifies the content of a complexType element.  As children, it can 
    have a simpleContent, a complexContent or a model group.  Only if it has 
    one of the latter two, may it have a mixed attribute.  This latter 
    constraint is something that cannot be specified in XML Schema.
  </doc:p>
  <choice>
    <ref name="simpleContent" />
    <group>
      <optional>
        <attribute name="mixed">
          <data type="boolean" />
        </attribute>
      </optional>
      <choice>
        <ref name="complexContent" />
        <group>
          <optional>
            <ref name="typeDefParticle" />
          </optional>
          <ref name="attrDecls" />
        </group>
      </choice>
    </group>
  </choice>
</define>

<define name="complexType">
  <doc:p>
    This specifies the basic content of a complexType element.
  </doc:p>
  <ref name="annotated" />
  <ref name="complexTypeModel" />
</define>

<define name="topLevelComplexType">
  <doc:p>
    This specifies the model for a complexType element at the top level of 
    the schema.  It must have a name, which provides a unique identifier 
    within the type symbol space.  It may have abstract, block and/or final 
    attributes.  Otherwise it is the same as other complexTypes.
  </doc:p>
  <element name="complexType"
        doc:href="http://www.w3.org/TR/xmlschema-1/#element-complexType">
    <ref name="complexType" />
    <attribute name="name">
      <data type="NCName" />
    </attribute>
    <zeroOrMore>
      <choice>
        <attribute name="abstract">
          <data type="boolean" />
        </attribute>
        <attribute name="block">
          <ref name="derivationSet" />
        </attribute>
        <attribute name="final">
          <ref name="derivationSet" />
        </attribute>
      </choice>
    </zeroOrMore>
  </element>
</define>

<define name="localComplexType">
  <doc:p>
    This specifies the model for a local complexType element.
  </doc:p>
  <element name="complexType"
        doc:href="http://www.w3.org/TR/xmlschema-1/#element-complexType">
    <ref name="complexType" />
  </element>
</define>

<define name="complexRestriction">
  <doc:p>
    This describes a restriction element within a complexContent element 
    (i.e. one that restricts a complex type).  It has a base attribute, may 
    contain a model group and may contain attribute declarations of various 
    sorts.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -