DEF Lines (Technical Reference)
The DEF line controls the generation of the GML application schema when the GML2 writer is set to FIXED or CREATE mode.
<WriterKeyword>_DEF <elementName> \ xml_type <xml_type> \ [<attrName> <attrType>]*
The interpretation of a DEF line is dependent on the GML2 writer’s SCHEMA_MODE.
FIXED Mode
The GML instance document output conforms to the FMEFeatures.xsd application schema (Safe Schema). Its namespace prefix is fme and its URL is http://www.safe.com/xml/schemas/FMEFeatures. A copy of the FMEFeatures.xsd schema document may be found under the xfMap folder of the FME installation. In most installations, this location is: C:\Program Files\FME_<version>\xfmap.
This schema declares two GML feature collection elements:
- fme:schemaFeatures
- fme:dataFeatures
(Please refer to the FMEFeatures.xsd schema, in the xfMap folder of your FME installation, for the declaration of the GML elements that are in the fme namespace.) Each collection element may contain 1 or more fme:Feature elements.
The fme:Feature can have a feature type, zero or more properties, and optionally one of the predefined geometric properties defined by the GML specification. (See the fme:FeatureType complex type definition in the FMEFeatures.xsd schema document.)
A DEF line specifies the contents of an fme:Feature in the fme:schemaFeatures container element. The <elementName> defines its feature type. Each <attrName> <attrType> pair defines an fme:property element. An additional fme:property with the name xml_type is defined by the value of the <xml_type>.
For example:
GML2_DEF Mexico \ xml_type xml_area \ State_Name xml_char(35) \ State_Code xml_char(8) \
causes the GML2 writer to generate, in the GML output instance, the following fme:Feature:
<fme:schemaFeatures> ... <gml:featureMember> <fme:Feature> <fme:featureType>Mexico</fme:featureType> <fme:property name=”xml_type”>xml_area</fme:property> <fme:property name=”State_Name”>xml_char(35)</fme:property> <fme:property name=”State_Code”>xml_char(8)</fme:property> </fme:Feature> </gml:featureMember> ... </fme:schemaFeatures>
When the GML2 Writer writes out an FME feature, it uses its feature type to determine how an fme:Feature element should be written in the fme:dataFeature container.
The FME feature’s feature type must equal one of the DEF lines (<elementName>). Through it, the writer determines the properties and geometry for the data fme:Feature. The geometry is determined by the DEF line’s <xml_type>. It determines which GML geometric primitive is needed in the fme:Feature.
The following table shows the correspondence:
xml_type |
GML v2 geometric property element referenced in the fme:Feature |
xml_no_geom |
none |
xml_point |
pointProperty, multiPointProperty |
xml_line |
lineStringProperty, multiLineStringProperty |
xml_area |
polygonProperty, multiPolygonProperty |
xml_text |
pointProperty |
CREATE Mode
One GML2 DEF line specifies the following in the GML application schema:
- XML Schema Complex Type Definition
- XML Schema Global Element Declaration
XML Schema Complex Type Definition
This complex type is named <elementName>Type
. It resides in the GML application schema target namespace that is specified with the Target Namespace Prefix and Target Namespace URI writer parameters. It derives by extension from the GML AbstractFeatureType.
The value of <xml_type>
determines which GML geometric property will be included as an element reference in the definition of the <elementName>Type
complex type.
The following table shows this relation:
xml_type |
GML v2 geometric property element referenced in the complex type |
xml_no_geom |
none |
xml_point |
pointProperty, multiPointProperty |
xml_line |
lineStringProperty, multiLineStringProperty |
xml_area |
polygonProperty, multiPolygonProperty |
xml_text |
Not supported in CREATE mode |
In the above table, if there is more than one GML geometric property element referenced, then the <elementName>Type
complex type definition will reference these inside an XML Schema choice element.
Each <attrName> <attrType>
in the DEF line specifies an element declaration in the <elementName>Type complex type. The element declaration name is <attrName> and its type is <attrType>
. The valid values for <attrType>
are: xml_buffer, xml_char(width), xml_int32, xml_real32, xml_decimal(width,decimal), xml_boolean
, and xml_real64
.
An <attrName>
may also be suffixed in the DEF line by {} to indicate that the attribute is a simple list attribute. The GML property generated for this simple list attribute will have its maxOccurs
set to unbounded.
XML Schema Global Element Declaration
This global element is declared with the name <elementName>, its type is <elementName>Type, and it is assigned to the GML _Feature substitution group.
The following GML2 DEF line:
GML2_DEF roads \ xml_type xml_line \ id xml_char(4) \ name xml_char(16) \ myList{} xml_char(64)
causes the GML2 Writer to generate the following for the GML2 application schema (assume that the GML application schema target namespace prefix is gml2, that the GML specification namespace prefix is gml, and that the XML Schema is in the default namespace [i.e., no prefix is required for the XML Schema elements]):
<complexType name=”roadsType”> <complexContent> <extension base=”gml:AbstractFeatureType”> <sequence> <element name=”id”> <simpleType> <restriction base=”string”> <maxLength value=”4”/> </restriction> </simpleType> </element> <element name=”name”> <simpleType> <restriction base=”string”> <maxLength value=”16”/> </restriction> </simpleType> </element> <element name=”myList” maxOccurs=”unbounded”> <simpleType> <restriction base=”string”> <maxLength value=”64”/> </restriction> </simpleType> </element> <choice> <element ref=”gml:lineStringProperty”/> <element ref=”gml:multiLineStringProperty”/> </choice> </sequence> </extension> </complexContent> </complexType> <!-- XML Schema global element declaration --> <element name=”roads” type=”gml2:roadsType” substitutionGroup=”gml:_Feature”/>