Xsi: Nil = "true"

Source: Internet
Author: User
Document directory
  • 2. Relax NG

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.