Token elements
The Token element outputs a string segment.
All output string segments for a given rule are concatenated in the
order that they are specified. This creates the string rule output
for the event, notification, labeling, and cross namespace naming
rules. Many of the Token element parameters work
together to control the behavior of the rule engine. These related
parameters are described below.
Purpose
The rule engine is directed to the current node by the nestedRelationship elements.
The actions performed by theToken element are performed
on the current node. If the Token element exists
outside any Relationship element, it acts against
the parameters of the root instance, the instance that was mapped
to the policy. Parameters
The following are the parameters
for the Token element. For purposes of these descriptions,
the term string refers to the value of the attribute identified by
the Token keyword attribute which the parsing function acts on:
- keyword and value parameters
- These parameters define the string value that is output as a string
segment.
- When the
keywordis set toATTR, thevalueis set to the attribute name that is to be output. - When the
keywordis set toLITERAL, thevalueis the literal that is output as the string segment - When the
keywordis set toFUNC, thevaluecan be set toclass,shortclass, orlabelwhich results in, respectively, the class name of the current resource, the rightmost part of the class name, and the display label of the current resource. - When the
keywordis set toSOURCETOKENand the value is set to a particular product name that provides the source token value along with their resource, attribute, and relationship data, the rule engine outputs the source token value for the resource.
- When the
- case (optional)
- The
caseparameter instructs the rule engine to apply the specified case to the output string. The possible values areUPPERandLOWER.
token, delimiters,
and string_delimiter optional parameters allow the
string outputted by the Token element to be manipulated
before it is output. - token (optional)
- The
tokenparameter instructs the rule engine how to manipulate a string before it is it outputted. Optional values for this parameter are contained in the ScrConfig.xml file includefirst,last,allButFirst,allButFirstTwo,allButFirstTwo,allButFirstTwo,firstTwo,lastTwo,findMatchOccurrence,format,excludeString,getExecutable, andjavaRegexReplace. Thetokenattribute works in conjunction with thedelimitersandstring_delimiterattributes.
- delimiters (optional)
- The
delimitersparameter specifies the delimiter used by the rule engine to break up the string. If more that one character is provided anyone of them causes the string to be broken up into segments. The default is a (.). Examples of other values include@,|, and:.
- string _delimiter (optional)
- The
string_delimiterparameter tells the rule engine to treat its value as a single delimiter. For example, you can use the stringatto break up the stringabbyatthispaceinto two tokensabbyandthis place.
Token element can also use regular
expression behaviors to extract data from a resource attribute value:- javaregex and occurrence parameters
- The
javaregexand theoccurenceparameters cause the nth matching region or occurrence of a regular expression within the input attribute value string
This returnsjavaregex = "a.b" occurrence=1 input string = "aababbacbadb"aab.
- javaregex and format parameters
- The form of the substitute pattern in the
formatstring is${n}where n represents the nth matching occurrence of the regular expression in the incoming string. You will always get an output so you must test the string if necessary to first detect if it should be acted upon. An example of this is:
If the input attribute value string, the value of the<Token keyword='ATTR' value='cdm:Name' javaregex="a.b" format="This ${1} and that ${2}" />cdm:Nameattribute for the current resource, isaabcccccabbacbadbthen the output string segment would beThis aab adn that abb.
- javaregexreplace
- This regular expression replaces regular expressions in the format string with the matched regions in the incoming string.
Optionally, a condition element
can be contained by, or is a sub-element of, the Token element.
In this case the parameter that the condition is acting upon is defined
by the string being outputted by the attributes of the Token element.