Powered by SmartDoc

mapKey

The extention syntax mapKey specifies to be available a map-key facility.

Parameter

The mapKey attribute takes one of the following values as a parameter.

true
Enables a map-key facility.
false
Disables a map-key facility.

Artifact

If value of the 'mapKey' attribute is true, the container class of the target property supports getter method to get the property by the key.

Example

List 8.10.3.1[grammarMapKey.rng] is a sample schema for the mapKey attribute.

grammarMapKey.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="accounts"/>
  </start>
  <define name="accounts">
    <element name="accounts">
      <zeroOrMore>
        <ref name="account"/>
      </zeroOrMore>
    </element>
  </define>
  <define name="account">
    <element name="account">
      <attribute name="accountNo" java:mapKey="true">
        <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">
      <attribute name="zip">
        <data type="token"/>
      </attribute>
      <text/>
    </element>
  </define>
  <define name="phone">
    <element name="phone">
      <attribute name="area">
        <data type="token"/>
      </attribute>
      <data type="token"/>
    </element>
  </define>
</grammar>