TransformAttributeResolver

Overview

Identified by type="Transform", this AttributeResolver applies one or more regular expressions to an input attribute, either replacing its values, or generating new attributes.

To use this plugin, the plugins.so shared library must be loaded via the <OutOfProcess> element's <Library> element.

The transforms to apply are specified using <Regex> child elements. Each element specifies a transform rule to apply to each value of the designated input attribute(s).

match attribute specifies a regular expression to match against the input value(s). It can contain parentheses to specify capturing groups. The content of the element is a replacement expression that can contain group placeholders to match the capturing groups (e.g., $1, $2, etc.). If the expression does not match, the value is passed through unchanged.

dest attribute, if present, specifies the ID of a new attribute to create that will contain the transformed values. If not present, the transformed values replace the original attribute's values "in-place", if and only if the original attribute was a "simple" string-valued attribute. Other attribute types with more complex values cannot be transformed in-place.

Finally, the caseSensitive attribute specifies whether the containing <Regex> element's match expression is to be interpreted case-sensitively. It is a boolean that defaults to "true".

Reference

Attributes

Name

Type

Req?

Description

Name

Type

Req?

Description

source

string

Y

Identifies the attribute ID of the input attribute(s) to process. All attributes with an ID that matches the value will be evaluated.

Child Element

Name

Cardinality

Description

Name

Cardinality

Description

<Regex>

1 or more

Specifies a transform rule to apply to each value of the designated input attribute(s). See above for details on the element function

Attributes

  • match (string, required): Specifies a regular expression to match against the input value(s). It can contain parentheses to specify capturing groups

  • dest (string, optional):Specifies the ID of a new attribute to create that will contain the transformed values. If not present, the transformed values replace the original attribute's values "in-place", if and only if the original attribute was a "simple" string-valued attribute. Other attribute types with more complex values cannot be transformed in-place.

Element Content

A replacement expression that can contain group placeholders to match the capturing groups (e.g., $1, $2, etc.). If the match expression does not match, the value is passed through unchanged.

Example

This is a bit overly simplistic, and assumes the source values are in a particular format.

The example parses a displayName attribute in the form "first last" and produces two separate attributes to carry each value alone, while also reversing the order in place.

<AttributeResolver type="Transform" source="displayName"> <Regex match="^(.+) (.+)$" dest="givenName">$1</Regex> <Regex match="^(.+) (.+)$" dest="sn">$2</Regex> <Regex match="^(.+) (.+)$">$2, $1</Regex> </AttributeResolver>