This should cover W3C XML Schema, Relax NG and DTD related problems.
- Posts: 20
- Joined: Sat Nov 26, 2005 5:17 pm
- Location: Houston, Texas, USA
I've defined an element that contains other elements. As far as I am concerned, the contained elements may appear in any order. The ixx, iyy, and izz elements are required and must appear once. The ixz, ixy, and iyz elements are each optional, and may appear once each. The ptmass element may or may not appear at all - and it may appear any number of times. I haven't yet been able to figure out how I can write a schema for this.
Right now, I've got this:
Code: Select all
<xs:element ref="ixx" minOccurs="1"/>
<xs:element ref="iyy" minOccurs="1"/>
<xs:element ref="izz" minOccurs="1"/>
<xs:element ref="emptywt" minOccurs="1"/>
<xs:element ref="location" minOccurs="1"/>
<xs:element ref="ptmass" minOccurs="0" maxOccurs="unbounded"/>
This is problematic, only
because I cannot specify the pointmass object as occurring any number of times.
Do I have any alternatives? The <sequence> item would work, except that the contained elements can appear in any order.
Open Source Flight Dynamics Model
- Site Admin
- Posts: 2102
- Joined: Thu Jan 09, 2003 2:58 pm
The default values for minOccurs and maxOccurs are 1 in both cases so you did not make the ixz, ixy, and iyz optional, you need to add a minOccurs="0" to have them optional. The problem is that 0 and 1 are the only values allowed for minOccurs/maxOccurs inside an all content model so you cannot say that some element can appear any numer of times.
As always, the solutions are to specify an order using sequence or create a more relaxed model for instance using choice and eventually enforce your constraints using Schematron embedded rules or at the application level.