DFDL language: scoping

Where to set properties for DFDL objects.

DFDL properties do not have built-in defaults. If an object needs a property, you must supply a value.
  • You can set the property locally, on the object itself.
  • You can set the property on a dfdl:format annotation within a named dfdl:defineFormat annotation. You can then use the special dfdl:ref property to reference the dfdl:defineFormat annotation.
  • You can set the property in the dfdl:format annotation of the schema. In this case, the property acts as a default for all objects in the schema.
Tip: The dfdl:ref property can also be used on a dfdl:format annotation, enabling inheritance chaining.
The following sample data shows the different ways that initiators a:, b:, and c: can be set:
<xs:schema>
  <xs:annotation>
    <xs:appinfo source="http://www.ogf.org/dfdl/" >   
      <dfdl:format initiator="c:" … />
    </xs:appinfo>
  </xs:annotation>

  <xs:annotation> <xs:appinfo source="http://www.ogf.org/dfdl/" >
      <dfdl:defineFormat name="myFormat" />
      <dfdl:format initiator="b:" … />
      </dfdl:defineFormat>
    </xs:appinfo>
  </xs:annotation>

  <xs:complexType>
    <xs:sequence dfdl:separator="," >
      <xs:element name="a" type="xs:string" dfdl:initiator="a:" 1  />
      <xs:element name="b" type="xs:string" dfdl:ref="myFormat" 2  />
      <xs:element name="c" type="xs:string" 3  />
    </xs:sequence>
  </xs:complexType>
</xs:schema>
Key:
  •  1  The dfdl:initiator property has been set locally.
  •  2  The dfdl:initiator property has been set in the defined format myFormat, and accessed by dfdl:ref.
  •  3  The dfdl:initiator property has been set in the dfdl:format annotation of the schema.