Sometimes it may take more than one mapping rule to successfully extract the geometric data from the elements in the input XML document stream. Consider the following polyline element:
<polyline> <coord>0.0,0.0</coord> <coord>1.1,2.2</coord> <coord>5.3,-1.9</coord> <coord>7.9,3.5</coord> </polyline>
Refer to FME Feature Construction (defining mapping rules under the <feature-content-map> element). It explains when mapping rules should be define under the <feature-content-map> element to handle cases like this one.
What we need here is to activate just one geometry builder B – one that constructs a line geometry. If we just define one feature mapping rule matching the <polyline> element, then we will not be able to give B the contents of all the <coord> elements because B gets suspended when the <polyline> element ceases to be the context element.
Recall that a suspended geometry builder may be set to the state of execution if the currently executing mapping rule contains a <geometry> element having no activate attribute.
We need to re-execute B and pass it the contents of the <coord> element when this element is matched. To achieve, this we define an additional feature mapping rule, that matches a <coord> element and contains a <geometry> element with no activate attribute.
The following xfMap document fragment does exactly this. The built-in geometry builder xml-line constructs polyline features.
<feature-map> <mapping match="polyline"> ... <geometry activate="xml-line"> </geometry> </mapping> </feature-map> <feature-content-map> <mapping match="coord"> ... <geometry> <!-- activate attribute missing, execute the suspended mapping rule passing it the parameters that are defined in the geometry. NOTE: It is an error to define a mapping rule of this form if no geometry builder was activated. --> <data name=”data-string”> <extract expr=”.”/> </data> </geometry> </mapping> </feature-content-map>