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.