Document directory
Http://www.xmlforasp.net/schemavalidator.aspx
Http://www.zvon.org/xxl/XMLSchemaTutorial/Output/ser_over_st0.html
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 This document is valid, the element "root" contains the "E1" element. <Root Xsi: nonamespaceschemalocation = "correct_0.xsd" xmlns = "" xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance" > <E1> XXX </E1>
</Root>Valid document This document is valid too, because the "xsi: Nil" attribute overrides element's definition and allows the element to be empty. <Root Xsi: nonamespaceschemalocation = "correct_0.xsd" Xsi: Nil = "true" xmlns = "" xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance" />Invalid document This document is not valid, because when "xsi: Nil" is true, the element must be empty (and "root" is not ). <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 This document is not valid, because the element "root" must have "E1" Child and "xsi: Nil" has not been set to "true ". <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> |
2. Relax NG
There is no such mechanic in Relax NG.