fmefunc Expressions

The fmefunc expression allows FME mapping file functions to be called. It is represented in the xfMap document with the <fmefunc> element, and it has the following general form:

<fmefunc expr=”...FME function specification...”>
	<arg> <!-- some expression sequence --> </arg>
	<arg> <!-- some expression sequence --> </arg>
	...
	<arg> <!-- some expression sequence --> </arg>
</selexpr>

The expression string (i.e., the expr attribute) specifies an FME function. FME functions are named with an “at” sign, @, as their first character. Both type of FME functions, i.e., feature and attribute functions, may be specified.

If the string in the expr attribute does not start with an @ sign, then its literal value is returned, otherwise the FME function is evaluated for its return value, bare in mind that FME feature functions do not return a value so an empty string is returned if this is the case.

The fmefunc expression may have 0 or more optional arguments that are expression sequences. Each expression sequence in an <arg> element should evaluate to an FME function specification, meaning that its first character must be the @, otherwise, the evaluated expression is simply concatenated as part of the final result for the fmefunc expression.

The evaluated value for an fmefunc expression is the concatenation of the results for all specified FME function specifications.

Each fmefunc expression works upon its own “scratch” FME feature allowing the possibility for algorithmic computations because the state of this temporary feature is not reset between the evaluation of the expression’s arguments and each argument is evaluated in order. Algorithmic calculations are achieved by “stacking up” a series of feature and or attribute FME functions.

Example

items.xml

<?xml version="1.0" encoding="UTF-8"?>
<items>
  <item>
    <primary-id>key0</primary-id>                              
    <alternate-id>he5390</alternate-id>   
    <geoLat>312129.20N</geoLat>
    <geoLong>0854453.20W</geoLong>	
  </item>   
</items>

items.xmp

<?xml version="1.0" encoding="UTF-8"?>   
<xfMap>
<feature-map>
  <mapping match="item">
    <feature-type><literal expr="item"/></feature-type>
    <attributes>
      <attribute>
        <name><literal expr="geoLat"/></name>
        <value><extract expr="./geoLat"/></value>
      </attribute>
      <attribute>
        <name><literal expr="geoLong"/></name>
        <value><extract expr="./geoLong"/></value>
      </attribute>                                    
    </attributes>

    <geometry activate="xml-point">
      <data name="data-string">
        <fmefunc expr="">                                          
          <note> @SupplyAttributes(geoLat,LAT,geoLong,LON) </note>
            <arg>
              <literal expr="@SupplyAttributes("/>
              <literal expr="geoLat,"/>
              <extract expr="./geoLat"/>
              <literal expr=",geoLong,"/>                                                
              <extract expr="./geoLong"/> 
              <literal expr=")"/>
            </arg>
            <arg>
<literal expr="@Angle(ATTRIBUTES,DDDMMSS.SSO,DECIMAL_DEGREES,geoLat,geoLong)"/>
	    </arg>
            <note> x,y </note>
            <arg><literal expr="@Value(geoLong)"/></arg>
            <arg><literal expr=","/></arg>
            <arg><literal expr="@Value(geoLat)"/></arg>                     
         </fmefunc>            
      </data>
    </geometry>                     
  </mapping>
</feature-map>               
</xfMap>

FME features constructed:

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Feature Type: `item'
Attribute(string): `fme_geometry' has value `fme_point'
Attribute(string): `geoLat' has value `312129.20N'
Attribute(string): `geoLong' has value `0854453.20W'
Attribute(string): `xml_type' has value `xml_point'
Geometry Type: Point (1)
Number of Coordinates: 1 -- Coordinate Dimension: 2 -- Coordinate System: `'
(-85.7481083333333,31.3581111111111) 
===================================================================

===================================================================