Creating a 'flexible' XML schema

后端 未结 2 1270
眼角桃花
眼角桃花 2021-01-13 05:01

I need to create a schema for an XML file that is pretty flexible. It has to meet the following requirements:

  1. Validate some elements that we require to be pres
2条回答
  •  长发绾君心
    2021-01-13 05:27

    Your requirement number 3 cannot be addressed if the name elements are optional because your schema would then violate the unique particle attribution rule (basically, the processor won't know whether to validate firstname against firstname or against any).

    You are not restricted to a single schema as far as validation is concerned. If you are ok with using two schemas in different namespaces, you can do this:

    Schema one - allow anything:

    
      
        
          
            
          
        
      
    
    

    Schema two - add specific validation for some elements:

    
        
        
    
    

    Then make sure your instance document's xsi:include references both schemas.

提交回复
热议问题