Powered by SmartDoc

role

The extention syntax 'role' specifies a parent class name for a target class.

Parameter

The role attribute takes a interface name list.

Artifact

Interfaces specified in the role attribute are generated. The classes which specifies role attribute implements the generated interfaces. The interfaces supports all common methods of concrete classes.

Example

List 8.11.3.1[grammarRole.rng] is a sample schema for the role attribute.

grammarRole.rng
<grammar xmlns="http://relaxng.org/ns/structure/1.0"
         xmlns:java="http://www.relaxer.org/xmlns/relaxer/java"
         datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
  <start>
    <ref name="account"/>
  </start>
  <define name="account">
    <element name="account">
      <attribute name="accountNo">
        <data type="token"/>
      </attribute>
      <element name="balance">
        <data type="int"/>
      </element>
      <element name="owner">
        <data type="token"/>
      </element>
      <ref name="address"/>
      <zeroOrMore>
        <ref name="phone"/>
      </zeroOrMore>
    </element>
  </define>
  <define name="address">
    <element name="address" java:role="IPart">
      <attribute name="zip">
        <data type="token"/>
      </attribute>
      <text/>
    </element>
  </define>
  <define name="phone">
    <element name="phone" java:role="IPart">
      <attribute name="area">
        <data type="token"/>
      </attribute>
      <data type="token"/>
    </element>
  </define>
</grammar>