XML schema construct for “any one or more of these elements but must be at least one”

后端 未结 3 1914
-上瘾入骨i
-上瘾入骨i 2020-12-03 17:06

I\'m trying to set up part of a schema that\'s like a \"Sequence\" where all child elements are optional, but at least one of the elements must be present,

3条回答
  •  盖世英雄少女心
    2020-12-03 17:34

    According to the technical article on MSDN titled Understanding XML Schema at http://msdn.microsoft.com/en-us/library/aa468557.aspx#understandxsd_topic5 you can take advantage of constraints such as minOccurs on the choice definition (compositor) itself:

    "Using occurrence constraints on a compositor applies to the entire group as a whole"

    (See the more sophisticated example that uses nested complex types and the AuthorType example)

    You stated your requirement as "at least one of the elements must be present, and there could be more than one of them". Thus, I propose you try the following:

    
        
        
    
    

提交回复
热议问题