Andrew Paterson wrote:
> [...]

I expected the first occurrence of "<elements>" to fail (neither
<element2> nor <element3> is present) but the file passed validation. Is
it Xerces-J (2.8.0), the schema or my understanding that is incorrect
and, if it is not the Xerces-J, is there a way to do what I want in a
W3C schema?

Note: Validation against a DTD showed the same problem.

Thanks,
Andrew



Hi Andrew,

it is not a bug, it is correct that the schema you've created accepts the <element> element that contains only the <element1>. As both elements in the "element_group" group are optional, it matches the non-existing elements after <element1>.

I'm not a schema expert, but I would create a choice of two, one requiring element2 and optionally accepting element3, the other requiring element3 (solely). Forgive me any syntax errors, as I am a bit lost without XMLSpy I'm using at my workplace. But I think you'll understand.

...
  <choice>
    <sequence>
      <element minOccurs="1" name="element2"/>
      <element minOccurs="0" name="element3"/>
    </sequence>
    <sequence>
      <element minOccurs="1" name="element3"/>
    </sequence>
  </choice>
...

Greetings,

Klaus

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to