XSD doesn't allow me to have unbounded inside all indicator

前端 未结 3 1016
醉梦人生
醉梦人生 2020-12-16 13:17

I\'m trying to make unordered list of variables in var1 occurs twice and var2 occurs infinite times (Use case in my project is different). The element does not allow me to

相关标签:
3条回答
  • 2020-12-16 13:37

    What you're trying to do sounds like the type of an element in your list might be ambiguous without reading-ahead, in which case there's no work around in XSD because of the classes of languages it can describe.

    Can you post up a the relevant part of your XSD?


    Update: No, you can't do that with XSD. The rules about what you can put in an <xs:all> element are listed for example here. This constraint has a name - the UPA, or Unique Particle Attribution constraint. It's all to do with ambiguity and the Microsoft website has a good explanation of why is exists here.

    You can either change your document layout to remove the need for this kind of declaration, or look to a more expressive schema language like RelaxNG.

    0 讨论(0)
  • 2020-12-16 13:38

    I came across the same problem and there is a solution! Check out this answer:

    https://stackoverflow.com/a/3827606/637142

    <xs:element name="A">
      <xs:complexType>
        <xs:choice maxOccurs="unbounded">
          <xs:element ref="B"/>
          <xs:element ref="C"/>
        </xs:choice>
      </xs:complexType>
    </xs:element>
    
    0 讨论(0)
  • 2020-12-16 13:38

    easy, simply use<xs:choice maxOccurs="unbounded"> instead of <xs:all>. This will give the effect you are looking for.

    0 讨论(0)
提交回复
热议问题