xml schema maxOccurs = unbounded within xs:all

前端 未结 1 505
醉梦人生
醉梦人生 2020-12-21 12:55

Is it possible to have a combination of xs:all and xs:sequence?

I\'ve have a xml structure with an element probenode which consist of the e

相关标签:
1条回答
  • 2020-12-21 13:37

    In XSD 1.0, the children of xs:all must have maxOccurs set to 1.

    In XSD 1.1 this constraint is lifted.

    So your alternatives appear to be:

    • Use an XSD 1.1 processor (Saxon or Xerces-J).

    • Use XSD 1.0 and impose an order on the children of probenodetype. This is a problem if the order in which the children appear carries information (so id followed by url is different from url followed by id ...).

    In some simple cases it's feasible to write a content model that accepts precisely what you suggest you want, using only choice and sequence, but with seven required elements the resulting content model is likely to be too long and complex to be useful.

    At this point some users give up and write a complex type with a repeatable OR-group and move the responsibility for checking that name, id, url, etc. all occur at least once and at most once into the application; that allows the generator of the XML not to have to worry about a fixed order (and opens a side channel for information leakage, which matters to some people) but also renders the schema somewhat less useful as documentation of the contract between data provider and data consumer.

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