[relaxng-user] open or extensible schemas

G. Ken Holman gkholman at CraneSoftwrights.com
Sat Apr 10 21:08:01 ICT 2004


At 2004-04-11 00:10 +0000, Eric Hanson wrote:
>Is there a way to define a schema that rather than saying what
>/can/ be present, just says what /must/ be present?
>...
>Can can there be schema that would validate the following
>document:
>...
>because foo and bar are present?  Basically I want to say that
>*anything* can be under element foo as long as bar is present.

Below is a brute-force way of ensuring there is at least one <bar/> ... I 
tried to use interleave but couldn't see a way to enforce the required element.

I hope this helps.

.................... Ken

T:\ftemp>type eric.rnc

start = element foo
    {
        element * - bar { empty }*,
        element bar { empty },
        element * - bar { empty }*
    }

# end of file

T:\ftemp>type eric1.xml
<foo>
   <bar/>
</foo>

T:\ftemp>jing -c eric.rnc eric1.xml

T:\ftemp>type eric2.xml
<foo>
   <bar/>
   <zonk/>
   <bonk/>
</foo>

T:\ftemp>jing -c eric.rnc eric2.xml

T:\ftemp>type eric3.xml
<foo>
   <zonk/>
   <bonk/>
</foo>

T:\ftemp>jing -c eric.rnc eric3.xml
T:\ftemp\eric3.xml:4: error: unfinished element

T:\ftemp>



--
Public courses: Spring 2004 world tour of hands-on XSL instruction
Each week:   Monday-Wednesday: XSLT/XPath; Thursday-Friday: XSL-FO
Hong Kong May 17-21; Bremen Germany May 24-28; Helsinki June 14-18

World-wide on-site corporate, govt. & user group XML/XSL training.
G. Ken Holman                 mailto:gkholman at CraneSoftwrights.com
Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/r/
Box 266, Kars, Ontario CANADA K0A-2E0    +1(613)489-0999 (F:-0995)
Male Breast Cancer Awareness  http://www.CraneSoftwrights.com/r/bc



More information about the relaxng-user mailing list