You are here: Popular Formats > XML (Extensible Markup Language) Reader/Writer > xfMap > Feature Mapping Rules > Attribute Element (handling optional attributes)

Attribute Element (Handling Optional Attributes)

Each attribute specified with the <attribute> element is added by default to an FME feature. A user may not want an attribute included in an FME feature when the expression sequence of an attribute’s value evaluates to the empty string. The <attribute> element has an optional required attribute that specifies if the attribute is to be given to the feature based on the evaluated expression sequence of its value. The valid values for the required attribute are true and false, with its default value being true.

If the optional required attribute is set to false, then the attribute will not be given to the feature when the expression sequence of its value evaluates to the empty string. The following xfMap fragment sets the required attribute to false.

<attribute required="false">
	<name> <literal expr="my-optional-attribute"/> </name>
	<value> <extract expr="."/> </value>
</attribute>