ZVON > Tutorials > XML Schema and Relax NG Tutorial |
Intro / Search / ZVON |
Index | >> Example 2 / 8 << | Prev | Next | |
The schema below defines an abstract element named "myAbstract" (attribute "abstract" is set to "true"). using the attribute "block" set to "substitution", we forbid all substitutions. I am not sure, if there can be any valid document :-).
Invalid document <root xsi:noNamespaceSchemaLocation="correct_0.xsd" xmlns="" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > <unchanged>7</unchanged> </root> |
Correct XML Schema (correct_0.xsd) <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" > <xsd:element name="root"> <xsd:complexType> <xsd:sequence minOccurs="1"> <xsd:element ref="myAbstract"/> </xsd:sequence> </xsd:complexType> </xsd:element> <xsd:element name="myAbstract" type="AAA" abstract="true" block="substitution"/> <xsd:simpleType name="AAA"> <xsd:restriction base="xsd:integer"> <xsd:minInclusive value="1"/> <xsd:maxInclusive value="9"/> </xsd:restriction> </xsd:simpleType> <xsd:element name="unchanged" substitutionGroup="myAbstract" type="AAA"/> </xsd:schema> |