<sequence>, <all>, or <choice>?
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
- Contact:
<sequence>, <all>, or <choice>?
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:
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.
Jon
Right now, I've got this:
Code: Select all
<xs:complexType>
<xs:all>
<xs:element ref="ixx" minOccurs="1"/>
<xs:element ref="iyy" minOccurs="1"/>
<xs:element ref="izz" minOccurs="1"/>
<xs:element ref="ixy"/>
<xs:element ref="ixz"/>
<xs:element ref="iyz"/>
<xs:element ref="emptywt" minOccurs="1"/>
<xs:element ref="location" minOccurs="1"/>
<xs:element ref="ptmass" minOccurs="0" maxOccurs="unbounded"/>
</xs:all>
</xs:complexType>
Do I have any alternatives? The <sequence> item would work, except that the contained elements can appear in any order.
Jon
Jon Berndt
Development Coordinator
JSBSim Project
Open Source Flight Dynamics Model
http://www.jsbsim.org
Development Coordinator
JSBSim Project
Open Source Flight Dynamics Model
http://www.jsbsim.org
-
- Site Admin
- Posts: 2095
- Joined: Thu Jan 09, 2003 2:58 pm
Hi Jon,
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.
Best Regards,
George
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.
Best Regards,
George
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service