Enforce further constraints on xsd:any?

前端 未结 2 1765
半阙折子戏
半阙折子戏 2020-12-22 03:51

I have an XSD 1.0 sequence that defines a set of elements, some of which may be optional but none of which can occur more than once, and which also ends with an

相关标签:
2条回答
  • 2020-12-22 04:42

    No, in XSD 1.0, once you've allowed any element, you can't specify further constraints beyond those afforded by minOccurs, maxOccurs, namespace, and processContents.

    In XSD 1.1, you can also make xsd:assertions against the xsd:any elements; you'd be able to express your constraint with an assertion. [Update: Don't miss @C. M. Sperberg-McQueen's simpler idea for XSD 1.1: xsd:any/@notQName="itemA itemB itemC"]

    0 讨论(0)
  • 2020-12-22 04:45

    Perhaps the simplest way to ensure that the elements itemA, itemB, and itemC are not repeated is to use namespace="##other" instead of namespace="##any". (This assumes that elements in the namespace testxsd other than those three will not need to appear here.)

    Or move to XSD 1.1 and add the attribute notQName="itemA itemB itemC".

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