Ignore order of elements using xs:extension

前端 未结 3 1374
粉色の甜心
粉色の甜心 2021-02-19 04:33

How can I design my xsd to ignore the sequence of elements?

   



        
3条回答
  •  说谎
    说谎 (楼主)
    2021-02-19 05:14

    MAJOR EDIT Originally I missed the requirement that you need to use xsd:extension. Note that xsd:extension works as if there was xsd:sequence with contents of the base type followed by contents of the extended type. As XML Schema Primer puts it:

    When a complex type is derived by extension, its effective content model is the content model of the base type plus the content model specified in the type derivation. Furthermore, the two content models are treated as two children of a sequential group.

    Therefore, it seems that the only way to make this work is to have an empty base type and store the whole alternative in the extended type, or vice versa (everything in the base and an empty extension). Like this:

    
       
          
             
                
                   
                   
                
                
                   
                   
                
             
          
       
    
    
    
    
    
    

提交回复
热议问题