ZVON > Tutorials > XML Schema and Relax NG Tutorial
Index | >> Example 3 / 3 << | Prev | Next |
Contents > Final > XML Schema - finalDefault attribute

XML Schema - finalDefault attribute

  1. Incorrect schema - finalDefault set to "#all"
  2. Incorrect schema - finalDefault set to "restriction"
  3. Correct Schema - finalDefault set to "extension"
XML Schema keys: finalDefault

1. Incorrect schema - finalDefault set to "#all"

The schema is not correct, because we have forbidden all further derivations of all types. 3.14.2 (non-normative) XML Representation of Simple Type Definition Schema Components .

Incorrect XML Schema (incorrect_0.xsd)


<xsd:schema finalDefault="#all" xmlns:xsd="http://www.w3.org/2001/XMLSchema" >

  <xsd:element name="root" type="AAA"/>

  <xsd:simpleType name="AAA">
    <xsd:restriction base="xsd:integer">
      <xsd:minInclusive value="0"/>
    </xsd:restriction>
  </xsd:simpleType>

  <xsd:simpleType name="BBB">
    <xsd:restriction base="AAA">
      <xsd:minInclusive value="10"/>
    </xsd:restriction>
  </xsd:simpleType>
</xsd:schema>

2. Incorrect schema - finalDefault set to "restriction"

The schema is not correct, because we have forbidden all further restrictions of all types. 3.14.2 (non-normative) XML Representation of Simple Type Definition Schema Components .

Incorrect XML Schema (incorrect_0.xsd)


<xsd:schema finalDefault="restriction" xmlns:xsd="http://www.w3.org/2001/XMLSchema" >

  <xsd:element name="root" type="AAA"/>

  <xsd:simpleType name="AAA">
    <xsd:restriction base="xsd:integer">
      <xsd:minInclusive value="0"/>
    </xsd:restriction>
  </xsd:simpleType>

  <xsd:simpleType name="BBB">
    <xsd:restriction base="AAA">
      <xsd:minInclusive value="10"/>
    </xsd:restriction>
  </xsd:simpleType>
</xsd:schema>

3. Correct Schema - finalDefault set to "extension"

The schema is correct, because we have forbidden all further extensions of all types, but restrictions are allowed. 3.14.2 (non-normative) XML Representation of Simple Type Definition Schema Components .

Valid document


<root xsi:noNamespaceSchemaLocation="correct_0.xsd" xmlns="" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >10</root>

Correct XML Schema (correct_0.xsd)


<xsd:schema finalDefault="extension" xmlns:xsd="http://www.w3.org/2001/XMLSchema" >

  <xsd:element name="root" type="AAA"/>

  <xsd:simpleType name="AAA">
    <xsd:restriction base="xsd:integer">
      <xsd:minInclusive value="0"/>
    </xsd:restriction>
  </xsd:simpleType>

  <xsd:simpleType name="BBB">
    <xsd:restriction base="AAA">
      <xsd:minInclusive value="10"/>
    </xsd:restriction>
  </xsd:simpleType>
</xsd:schema>