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

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

This is a part of my xml schema


    
        
              


        
2条回答
  •  南方客
    南方客 (楼主)
    2021-01-17 23:15

    You have to limit yourself a little bit, some of the things you are trying to do are not possible in XML Schema.

    Suppose you introduce a complex type called Person to be a super-type of Friend and Coworker. Here are your options:

    1. Replace xs:all with xs:sequence, remove name and phone from the sub-types, add to the super-type, and add inheritance. Your elements now have to be ordered, but you can make them individually optional. It is illegal to use xs:all in type hierarchies in XML Schema, because the processor cannot tell where the parent content model stops and the child content model starts.
    2. Replace xs:all with in both types, and add your inheritance. Then your elements become unordered again, but they may repeat.

    So in conclusion: given your type names up there, I would guess that your requirements will not be exactly met. I would go for the first option: insisting on arbitrary element order is often not as useful as it seems.

提交回复
热议问题