RELAX Quick Reference
| Download available |
For future reference, download the RELAX quick reference guide (.pdf) |
Your entire specification must be wrapped in a
<module>
<module
moduleVersion="1.2"
relaxCoreVersion="1.0"
targetNamespace=""
xmlns="http://www.xml.gr.jp/xmlns/relaxCore">
<interface>
<export label="root-element"/>
</interface>
<!-- specifications follow -->
</module>
In the tables below, items in gray like this are optional. Items in italics like this indicate values that depend upon your particular application.
Specifying Elements
| To specify: | RELAX |
|---|---|
|
An empty element
Note: all element rules may have a |
<elementRule role="name" label="name2"> <empty/> </elementRule> |
| Element with no sub-elements |
<elementRule role="name" type="datatype"/> |
|
Element with constraints on content |
<elementRule role="name" type="datatype"> <constraint value="constraint-value"/> </elementRule>Example: <elementRule role="age" type="integer"> <minInclusive value="18"/> <maxInclusive value="65"/> </elementRule> |
| Element with a single sub-element |
<elementRule role="name"> <ref label="sub-element/> </elementRule> |
|
Element with sub-elements that must occur in a particular order
The |
<elementRule role="name">
<sequence occurs="n">
<ref label="sub-element1" occurs="n"/>
<ref label="sub-element2" occurs="n"/>
</sequence>
</elementRule>
|
| Element with sub-elements that may appear in any order |
<elementRule role="name">
<choice occurs="n">
<ref label="sub-element1" occurs="n"/>
<ref label="sub-element2" occurs="n"/>
</choice>
</elementRule>
|
|
Mixed content element (element can contain text that is not within any of the sub-elements)
The |
<elementRule role="name">
<mixed>
<ref label="sub-element"/>
</mixed>
</elementRule>
|
|
A content model for re-use by other elements: Hedge rules may refer to other hedge rules, but may not have mixed content or data types. |
<hedgeRule label="hedge-rule-label"> <!-- content model as in elementRule --> </hedgeRule> |
|
Reference to a
You may intersperse |
<elementRule role="name"> <hedgeRef label="hedge-rule-label"/> </elementRule> |
Specifying Tags
Each element in a document is associated with tag. The
role= in an <elementRule> matches
the tag name.
| To specify: | RELAX |
|---|---|
|
A tag with no attributes
All tags may have a |
<tag label="name" role="tag-role"/> |
|
A tag with attributes You may specify that an attribute is required, or that it has a particular data type, or both. |
<tag label="name">
<attribute name="attr-name-1"/>
<attribute name="attr-name-2" required="true"/>
<attribute name="attr-name-3" type="datatype"/>
<attribute name="attr-name-4"
required="true"
type="datatype"/>
</tag>
|
|
Constraint on an attribute |
<tag label="name">
<attribute name="attr-name" type="datatype">
<constraint value="constraint-value"/>
</attribute>
</tag>
Example:
<tag label="water">
<attribute name="temp" type="decimal">
<minInclusive value="0"/>
<maxInclusive value="100"/>
</attribute>
</tag>
|
|
A set of attributes for re-use by other tags: |
<attPool role="pool-label"> <!-- list of attributes as in tag--> </attPool> |
|
Reference to an
You may intersperse |
<tag label="name"> <ref role="pool-label"/> </tag> |
Context Sensitivity
To make an element's content model dependent upon the element in which it is nested:
-
Define two
<elementRule>models with the samerolebut differentlabels. -
Other
<elementRule>s may now contain the desired sub-element by referring to the appropriatelabel.
To make an element's content model dependent upon the value of its tag's attribute:
-
Define two
<elementRule>models with the samelabelbut differentroles. -
Create
<tag>s with identicalnames. Each of these will refer to the appropriateroledefined in step one, and have an<attribute>to differentiate them.