[relaxng-user] specifying attribute choice

G. Ken Holman gkholman at CraneSoftwrights.com
Mon Feb 9 12:25:02 ICT 2004


At 2004-02-09 12:00 -0500, DuCharme, Bob (LNG-CHO) wrote:
>I'm trying to figure out how I can specify that an element must have at
>least one of a certain set of attributes and may have the others as well. If
>the attributes are called x, y, and z, I could say something like ((x & y?
>&z?) | (x? & y & z?)| (x? & y? & z)), but it doesn't scale up well.
>Something like
>
>   attlist.a =
>     (attribute x {text},
>      attribute y {text},
>      attribute z {text})+

Close, Bob ... just change "," to "|".

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

Y:\samp>type bob.rnc
start = element doc { attlist.a }

attlist.a =
     (attribute x {text} |
      attribute y {text} |
      attribute z {text})+


Y:\samp>type bob.xml
<doc/>
Y:\samp>jing -c bob.rnc bob.xml
Y:\samp\bob.xml:1: error: unfinished element

Y:\samp>type bob2.xml
<doc y="hello"/>
Y:\samp>jing -c bob.rnc bob2.xml

Y:\samp>type bob3.xml
<doc y="hello" x="goodbye"/>
Y:\samp>jing -c bob.rnc bob3.xml

Y:\samp>


--
Public courses: upcoming world tour of hands-on XSL training events
Each week:    Monday-Wednesday: XSLT/XPath; Thursday-Friday: XSL-FO
Washington, DC: 2004-03-15            San Francisco, CA: 2004-03-22
Hong Kong: 2004-05-17    Germany: 2004-05-24    England: 2004-06-07
World-wide on-site corporate, government & user group XML 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