How to restrict number of child elements in XSD 1.0?

160 Views Asked by At

I have XML(1.0) like the following:

<Elements>
  <ChildElement1> 
      <GrandChildEle1/>
      <GrandChildEle2/>
      <GrandChildEle3/>
      <GrandChildEle4/>
  </ChildElement1>
  <ChildElement2> 
      <GrandChildEle5/>
      <GrandChildEle6/>
      <GrandChildEle7/>
  </ChildElement2>
</Elements>

All the child elements and grandchild elements have different names.

My question is: How to restrict the total number of GrandChildElements within the same rlements (not child elements) to be less than 5 in XSD? For example, if Childelement1 has 3 GrandChildElement listed, then ChildElement2 can only have up to 2 GrandChildElements.

0

There are 0 best solutions below