ZVON > Tutorials > XML Schema and Relax NG Tutorial |
Intro / Search / ZVON |
Index | >> Example 7 / 8 << | Prev | Next | |
The "block" attribute can be useful to prevent overriding of our schema with "xsi:type" attribute in the document.
Valid document <root xsi:noNamespaceSchemaLocation="correct_0.xsd" bbb="1" xmlns="" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" /> Invalid document <root xsi:noNamespaceSchemaLocation="correct_0.xsd" bbb="1" xsi:type="BBB" xmlns="" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" /> |
Correct XML Schema (correct_0.xsd) <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" > <xsd:element name="root" type="AAA" block="extension"/> <xsd:complexType name="AAA"> <xsd:attribute name="bbb" type="xsd:string" use="required"/> </xsd:complexType> <xsd:complexType name="BBB"> <xsd:complexContent> <xsd:extension base="AAA"> <xsd:attribute name="ccc" type="xsd:string" use="required"/> </xsd:extension> </xsd:complexContent> </xsd:complexType> </xsd:schema> |