XQuery Functions

Feature Data Functions

Feature Processing Functions

Geometry Data Functions

Geometry Processing Functions

Published Parameters

Feature Data Functions

FME provides functions that can be used within XQuery scripts. These functions allow XQuery scripts and templates to access and manipulate feature attribute values.

All feature functions are prefixed with the fme namespace prefix.

Feature Processing Functions

Using the XMLTemplater and JSONTemplater, the template can include the results of processing a sub-template. There are two functions that allow sub-templates to be processed.

Geometry Data Functions

FME provides a number of functions for accessing geometry data using XQuery. All geometry data functions are prefixed with the “geom” namespace prefix.

Geometry Processing Functions

When evaluating a template, XQuery functions now have access to geometry. By default, the geometry which is accessed is simply the geometry associated with the feature which is being processed. However, using the functions described in this section, the geometry which is being processed may be changed. For example, if a feature’s geometry is an aggregate, the geom:process-parts function may be used to sequentially evaluate a sub-template on each part of the aggregate. While these sub-templates are being evaluated, the geometry data functions listed above will access the individual parts of the aggregate, rather than the aggregate as a whole.

Note that it is possible for a template to be called recursively, if a different geometry is being accessed in each evaluation of the template. This allows the processing of nested aggregate geometries to arbitrary depths, simply by using the geom:process-parts function.

Each of these functions, except the geom:process-points function, takes a parameter which defines which template to run for different geometry types. This mapping is done using an XML element, named ‘conf’ which contains attributes for the different geometry types. The attribute values contain the name of the template which is to be run for that geometry type. If a geometry does not have a type attribute in the conf element, or if the attribute contains an empty string, no template will be evaluated.

Example

If the following conf element is passed to a function, the function will evaluate the ROAD template on all line geometries, the POI template on all point geometries, and the PARCEL template on all polygon geometries.

<conf line="ROAD" point="POI" polygon="PARCEL" />

The following values are valid geometry type names for the conf element:

aggregate box brepsolid
composite-solid composite-surface csgsolid
donut ellipse extrusion
face line mesh
multi-area multi-curve multi-point
multi-solid multi-surface multi-text
null path point
pointcloud polygon raster
rectangle-face text triangle-fan
triangle-strip    

In addition to the above type names, there are a number of attributes that may be used in the conf element to name a template to run for a group of related geometry types.

Conf Attribute Name Effect
all The named template will be evaluated for geometries of any type.
area The named template will be evaluated for polygon, donut and ellipse geometries.
collection The named template will be evaluated for aggregates and multi-geometries, such as multi-points, multi-curves, etc.
curve The named template will be evaluated for line, arc and path geometries.

If more than one conf attribute name is applicable to a geometry, the value of the more specific attribute name will be used. Thus, the value of the all will only be used if no other attributes are applicable.

Example

If the following conf element is passed to a function, the function will evaluate the PATH template on all line and arc geometries, the PATH template on path geometries, and the OTHER template on all other geometries.

<conf curve="SEGMENT" path="PATH" all="OTHER" />

While these conf elements name a template to run geometries of a particular type, a geometry trait may be used to name a template which is to be run for a particular geometry instance. Setting the geometry_template trait on a particular geometry to a template name will make the functions run that template for that geometry, rather than the template named in the conf element.

Published Parameters

The XQueryFactory can retrieve the values of any published parameters (or macros) in a workspace (or mapping file).  These values are global variables in a query, and may be accessed using the ‘fme’ prefix and the parameter/macro name.  For example, to access the FME_HOME macro value, the $fme:FME_HOME variable may be used.  Due to a restriction of the XQuery language, parameters/macros whose names begin with a number are not accessible in this way.