Further Specifications

<<< Here's the <temperature> part of the weather report:

  <temperature>
     <min>20</min>
     <max>29</max>
     <forecast-low>21</forecast-low>
     <forecast-high>30</forecast-high>
  </temperature>

A <temperature> has four sub-elements. We want them all to be within a reasonable range of Celsius temperatures. The current version of RELAX doesn't let you make a single definition and reuse it four times. Thus, you have to type all the specifications for the sub-elements individually. Note that it is also possible to put the <tag> element inside the <elementRule>

    <elementRule role="min" type="integer">
        <tag name="min"/>
        <minInclusive value="-70"/>
        <maxInclusive value="70"/>
    </elementRule>

    <elementRule role="max" type="integer">
        <tag name="max"/>
        <minInclusive value="-70"/>
        <maxInclusive value="70"/>
    </elementRule>

    <elementRule role="forecast-low" type="integer">
        <tag name="forecast-low"/>
        <minInclusive value="-70"/>
        <maxInclusive value="70"/>
    </elementRule>

    <elementRule role="forecast-high" type="integer">
        <tag name="forecast-high"/>
        <minInclusive value="-70"/>
        <maxInclusive value="70"/>
    </elementRule>

Once these are defined, the specification of the <temperature> element is straightforward:

    <elementRule role="temperature">
        <sequence>
            <ref label="min"/>
            <ref label="max"/>
            <ref label="forecast-low"/>
            <ref label="forecast-high"/>
        </sequence>
    </elementRule>
    <tag name="temperature"/>

Now, it remains only to define the <wind> portion of the weather report. >>>

  1. Validating XML with RELAX
  2. Validity and the DTD
  3. Validity and RELAX
  4. Specifying Elements
  5. Making Validation More Specific
  6. Further Specifications
  7. Enumerations
  8. The Big Picture
  9. Summary