IfAttribute

The <IfAttribute> element makes operations conditional on the presence of a metadata field attribute.

Using <IfAttribute> does not change the context (the current position in the document).

Attribute Description
name The name of an existing attribute.
nameRegex A regular expression to match the name of one or more existing attributes.
negate Set this attribute to true to perform the child operations only when there are no matching attributes.

The following attributes filter the matching attributes by their values:

Attribute Description
containsRegex The attribute value must contain a match to this regular expression.
matches The attribute value must match this value exactly.
matchesRegex The whole attribute value must match this regular expression.
matchType

Specifies the conditions necessary for the child operations to be performed:

  • all - all attributes selected by nameRegex must have the specified value.
  • any - one or more of the attributes selected by nameRegex must have the specified value.
  • none - none of attributes selected by nameRegex must have the specified value.

In the following example, the field "myField" is deleted, but only if it has the attribute "expired" with the value "true". The <IfAttribute> element does not change the context, so it is the field that is deleted, not just the attribute.

<FieldStandardization>
    <Field name="myField">
         <IfAttribute name="expired" matches="true">
             <Delete/>
         </IfAttribute>
    </Field>
</FieldStandardization>