xsd: How to extend a type with an unordered list of elements

后端 未结 2 449
天涯浪人
天涯浪人 2021-01-17 22:28

This is a part of my xml schema


    
        
              


        
2条回答
  •  孤城傲影
    2021-01-17 23:02

    One-and-half year after this question and the accepted answer were posted, XSD 1.1 was published. In this version it is possible to specify what the OP asked for because a number of restriction on xs:all were lifted. One of them is that it is now possible to extend an xs:all.

    Using XSD 1.1 you can specify the following:

    
        
            
            
        
    
    
        
            
                
                    
                
            
        
    
    
        
            
                
                    
                
            
        
    
    

    This defines the following types:

    • Person: an abstract type with optional unordered name and phone elements;
    • Friend: extends Person adding an optional address element to the list of unordered elements;
    • Coworker: extends Coworker adding an optional office element to the list of unordered elements.

    Note that this solution does not work for every XML processor: even though 8 years have passed since the publication of XSD 1.1, a lot of processors still only support XSD 1.0.

提交回复
热议问题