[relaxng-user] Problem defining list of enumerated string values

Ken Beesley Ken.Beesley at xrce.xerox.com
Fri Feb 20 13:17:17 ICT 2004


I'm having trouble defining a Relax NG schema to match an element
that contains a list of strings that are constrained to be from a (large)
enumeration of possible values.

The element will look something like this

<input>a b space bell</input>

where the content is a whitespace-separated list of one to four strings.
The allowable strings must be enumerated somewhere in the schema.

***

I suspect that there's an embarrassingly simple solution, but so far
I haven't found it.

I tried

<define name="Input">
    <element name="input">
      <!-- for now, allow up to 4 input items -->
      <list>
        <ref name="GDK_input_item"/>
        <optional>
          <ref name="GDK_input_item"/>
          <optional>
            <ref name="GDK_input_item"/>
            <optional>
              <ref name="GDK_input_item"/>
            </optional>
          </optional>
        </optional>
      </list>
    </element>
  </define>

with

   <define name="GDK_input_item">
      <data type="string">
        <param name="enumeration">a</param>
        <param name="enumeration">b</param>
        <param name="enumeration">c</param>
       ...
        <param name="enumeration">space</param>
        <param name="enumeration">bell</param>
        <param name="enumeration">etc</param>
        ...
    </data>
  </define>

But I get the message that "the enumeration facet is not allowed--
use value element instead".

So then I tried the following, with <value> elements

   <define name="GDK_input_item">
      <data type="string">
        <value>a</value>
        <value>b</value>
        <value>c</value>
       ...
        <value>space</value>
        <value>bell</value>
        <value>etc</value>
        ...
    </data>
  </define>

but it didn't like that either.  The error message tells me that "only
param and except child elements are allowed" !!!  I tried putting
<choice>...</choice> around the <value> elements, but that was duly
rejected.

I also tried

   <define name="GDK_input_item">
      <choice>
        <value>a</value>
        <value>b</value>
        <value>c</value>
       ...
        <value>space</value>
        <value>bell</value>
        <value>etc</value>
        ...
    </data>
  </choice>

but <list> seems to want to contain <data> elements.

*******************************************************

So, just how does one write a schema that accepts elements like

<input>z foo bar veep</input>

where the items of the list come from a (large) enumeration of allowed
strings.

Thanks,

Ken Beesley
ken.beesley at xrce.xerox.com



More information about the relaxng-user mailing list