to the main page about the tutorial  THE XML REVOLUTION  -  TECHNOLOGIES FOR THE FUTURE WEB back up next

Regular expressions

Both attribute values and element content models are described by regular expressions.

Regular expressions can be built from:

Example:

...
  <union>
    <string value="*"/> 
    <stringtype ref="r:NUMBER"/>
  </union>
...

<stringtype id="r:DIGITS">
  <repeat min="1">
    <char min="0" max="9"/>
  </repeat>
</stringtype>

<stringtype id="r:NUMBER">
  <sequence>
    <stringtype ref="r:DIGITS"/>
    <optional>
      <sequence>
        <string value="."/>
        <stringtype ref="r:DIGITS"/>
      </sequence>
    </optional>
  </sequence>
</stringtype>

Libraries of common expressions can be made with the import feature described later...

If multiple regular expressions are declared for the contents of an element, they are implicitly combined by projection:

  <contents>
    <sequence>
      <element name="p:a"/>
      <element name="p:b"/>
    </sequence>
  </contents>

  <contents>
    <sequence>
      <element name="p:a"/>
      <optional><element name="p:c"/></optional>
    </sequence>
  </contents>

Here, an a element must be followed by a b element and optionally by a c element, but the b and c elements can appear in any order.

back COPYRIGHT © 2000-2003 ANDERS MØLLER & MICHAEL I. SCHWARTZBACH next