xml editor

Products

Features

  EPUB
Supported platforms

Supports Windows 7 & Mac OS X Lion

Ready for XML Editor data server software
W3C Member

Require non-empty sequence

This should cover W3C XML Schema, Relax NG and DTD related problems.

Require non-empty sequence

Postby ra0543 » Thu Jul 29, 2010 12:48 pm

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.
ra0543
 
Posts: 76
Joined: Wed Jan 14, 2009 12:50 pm

Re: Require non-empty sequence

Postby george » Mon Aug 02, 2010 9:27 am

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
George Cristian Bina
george
Site Admin
 
Posts: 2033
Joined: Thu Jan 09, 2003 2:58 pm


Return to XML Schemas

Who is online

Users browsing this forum: No registered users and 0 guests

XML Editor | XML Author | WYSIWYG Editors | Schema Editor | XSD Documentation | XSL/XSLT Editor | XQuery | XML Databases | SVN Client
© 2002-2011 SyncRO Soft Ltd. All rights reserved. | Sitemap | Privacy Policy | This website was created & generated with <oXygen/>® XML Editor