Require non-empty sequence
This should cover W3C XML Schema, Relax NG and DTD related problems.
-
- Posts: 80
- Joined: Wed Jan 14, 2009 12:50 pm
Require non-empty sequence
I'm using Schema to define the structure of my XML. At this stage it's not going to be easy to switch to a different metalanguage.
Can I define an element <parent> that has a sequence of child elements which are individually optional (i.e. no specific one is required) but where at least one has to be present?
So the following are OK:
<parent><a/></parent>
<parent><b/></parent>
<parent><c/></parent>
<parent><d/></parent>
<parent><a/><b/></parent>
<parent><b/><d/></parent>
<parent><a/><b/><c/><d/></parent>
but the following are invalid:
<parent><c/><a/></parent>
<parent/>
I think this is impossible using just Schema, but perhaps I'm missing some easy way of doing it.
Can I define an element <parent> that has a sequence of child elements which are individually optional (i.e. no specific one is required) but where at least one has to be present?
So the following are OK:
<parent><a/></parent>
<parent><b/></parent>
<parent><c/></parent>
<parent><d/></parent>
<parent><a/><b/></parent>
<parent><b/><d/></parent>
<parent><a/><b/><c/><d/></parent>
but the following are invalid:
<parent><c/><a/></parent>
<parent/>
I think this is impossible using just Schema, but perhaps I'm missing some easy way of doing it.
-
- Site Admin
- Posts: 2095
- Joined: Thu Jan 09, 2003 2:58 pm
Re: Require non-empty sequence
You can define that as a choice of
a followed by the other optional elements (b, c, d, etc.)
b followed by the other optional elements (c, d, etc.)
c followed by the other optional elements (d, etc.)
etc.
If you have 4 elements then in DTD like notation that will be
(a, b?, c?, d?) | (b, c?, d?) | (c, d?) | d
Best Regards,
George
a followed by the other optional elements (b, c, d, etc.)
b followed by the other optional elements (c, d, etc.)
c followed by the other optional elements (d, etc.)
etc.
If you have 4 elements then in DTD like notation that will be
(a, b?, c?, d?) | (b, c?, d?) | (c, d?) | d
Best Regards,
George
George Cristian Bina
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