ZVON > Tutorials > XML Schema and Relax NG Tutorial |
Intro / Search / ZVON |
Index | >> Example 1 / 2 << | Prev | Next | |
We can override the schema declaration when setting xsi:nil attribute to value "true". The schema must allow this by setting attribute "nillable" to "true" (default value is "false").
Valid document <root xsi:noNamespaceSchemaLocation="correct_0.xsd" xmlns="" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > <e1>xxx</e1> </root> Valid document <root xsi:noNamespaceSchemaLocation="correct_0.xsd" xsi:nil="true" xmlns="" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" /> Invalid document <root xsi:noNamespaceSchemaLocation="correct_0.xsd" xsi:nil="true" xmlns="" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > <e1>xxx</e1> </root> Invalid document <root xsi:noNamespaceSchemaLocation="correct_0.xsd" 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" nillable="true"> <xsd:complexType> <xsd:sequence> <xsd:element name="e1" type="xsd:string"/> </xsd:sequence> </xsd:complexType> </xsd:element> </xsd:schema> |
There is no such mechanism in Relax NG.