← Prev in month ← Prev in thread

RELAX NG require oneOrMore optional elements

From
Frank Cusack <>
To
Date
2008-07-15T19:39:55Z
ID
<>
Thread
RELAX NG require oneOrMore optional elements
Is it possible to require one or more from a list of optional elements?
If I have something like:

<element name="parent">
 <oneOrMore>
  <interleave>
    <optional>
     <element name="child1">
      <text/>
     </element>
    </optional>
    <optional>
     <element name="child2">
      <text/>
     </element>
    </optional>
  </interleave>
 </oneOrMore>
</element>

My intent is that <parent> must have at least 1 of the child elements.
But python-lxml (which I guess is libxml2) doesn't flag

<parent />

as erroneous.  Note that my actual list of child elements is quite long.

I also tried <oneOrMore><choice>...</choice></oneOrMore> and removing
all the <optional> wrappers.  This does require that at least one child
be present but doesn't prevent repetition of child elements.  I thought
about adding xsd:maxOccurrence attributes to each child element but
I'm not sure how to get the RelaxNG parser to understand them.

-frank
← Prev in month ← Prev in thread