Validate elements that can be empty with XSD

Say you have an element looking like this:


    Catcher in the rye

and that element is allowed to also be empty. Like this:


    <book/>

How do you validate it? One way is to use the attribute “nillable” like this


  
    
      <xs:element name="book" type="xs:string" nillable="true"/>
        
      
 

This will validate both a “book” element that is empty and one that is not

Comments are closed.

Niklas Tech Blog
Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.