selexpr Expressions

The selexpr expression returns the first, last, or the ith non-empty evaluated expression sequence from its argument list. It is represented in the xfMap document with the <selexpr> element, and it has the following general form:

<selexpr expr=”...”>
	<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 the first, last, or ith evaluated non-empty expression sequence to be returned. The valid values for the expression string are first, last, or a positive integer between 1 and k, where k is the number of arguments.

Example

items.xml

<?xml version=”1.0”?>
<items>
	<item>
		<primary-id>p9384</primary-id>
		<alternate-id></alternate-id>
	</item>
	<item>
		<primary-id></primary-id>
		<alternate-id>a2046</alternate-id>
	</item>
	<item>
		<primary-id></primary-id>
		<alternate-id></alternate-id>
	</item>
</items>

selexpr.xmp

<?xml version=”1.0”?>
<xfMap>
	<feature-map>
		<mapping match=”item”>
			<feature-type> 
				<selexpr expr=”first”/>
				<arg> <extract expr=”./primary-id”/> </arg>
				<arg> <extract expr=”./alternate-id”/> </arg>	
				<arg> <literal expr=”no-id”/> </arg>
			</selexpr>
			</feature-type>
		</mapping>
	</feature-map>
</xfMap>

FME features constructed:

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Feature Type: `p9384'
Attribute(string): `xml_type' has value `xml_no_geom'
Geometry Type: Unknown (0)
===================================================================
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Feature Type: `a2046'
Attribute(string): `xml_type' has value `xml_no_geom'
Geometry Type: Unknown (0)
===================================================================
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Feature Type: `no-id'
Attribute(string): `xml_type' has value `xml_no_geom'
Geometry Type: Unknown (0)
===================================================================