xml - Is it possible to restrict elements to a max occur in a "choice" block? -


i need solve following problem.

//pseudo algorithm

  • you have 4 elements: elm1, elm2, elm3, elm4
  • elm1 occurs 0-2 times
  • elm2 occurs 0-1 times
  • elm3 occurs 0-n times
  • elm4 occurs 0-n times
  • they can ordered in way, occur restricted given count.

//pseudo end

it seems combination of sequence , choice, both indicators have characteristic, don't allow me desired behavior.

sample: elm4 elm1 elm2 elm1 elm3 elm3 elm3 elm4

please rescue me before i'll insane :)

chris

if n values not big , you're desperate can make content model accounted every possible combination, grows complex exponentially.

the best solution use tool supports xml schema 1.1 (such xerces or saxon), relaxes restrictions on all group occurrence values. section g.1.3 of spec:

  1. several of constraints imposed version 1.0 of specification on all-groups have been relaxed:

    a. wildcards allowed in groups.

    b. value of maxoccurs may greater 1 on particles in group. elements match particular particle need not adjacent in input.

    c. groups can extended adding more members them.

failing that, general xml schema 1.0 solution specify relaxed model in schema (no limits on element occurrences) , enforce constraints care in layer, might custom code or xslt, instance.


Comments

Popular posts from this blog

linux - Mailx and Gmail nss config dir -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -