Syntax for Algorithm Arguments
From within the AttrValue, AttrConstraint, Value, and VarDef tags, there are three tags that you can use to specify arguments for the out-of-the-box object initialization rule algorithms. Although, each algorithm has a unique set of required arguments, the arguments fit into the following categories:
For string arguments, use the Arg tag.
For arguments that you want evaluated as an attribute, use the Attr tag.
For all arguments that are not strings or attributes, use the Value tag. For example, use the Value tag to specify additional algorithms.
Additionally from within the AttrValue, AttrConstraint, and Value tags, you can specify an argument that is the value of a rules variable using the VarRef tag.
The following sections describe the syntax for each argument and provide examples that use the arguments.
Arg Tag Syntax
The Arg tag syntax is as follows:
<Arg>string</Arg>
* 
Spaces used in an Arg tag will be ignored. To indicate a space, use a hyphen (-) or another character instead. If you need to include XML reserved characters in your string, the string must be defined as a CDATA section. Reserved characters include ampersand (&) and left and right angle brackets (< >). For example, if your Arg tag will include the ampersand character (&), use the following syntax to ensure that it works as expected: <Arg><![CDATA[Text &amp; Text]]></Arg>.
Attr Tag Syntax
The Attr tag syntax is as follows:
<Attr id="attribute_name"/>
where attribute_name is the name of an existing attribute that you want to use when executing the algorithm. For the attribute name, use the value specified in the Internal Name field when the attribute was created.
* 
If an attribute does not have a corresponding internal name, users who can modify the attribute can add one using the Type and Attribute Management utility.
Value Tag Syntax
The syntax of the Value tag depends on what value you are specifying. Inside the Value tag, you can specify additional arguments using any of the supported tags.
VarRef Tag Syntax
The VarRef tag syntax is as follows:
<VarRef id="variable_name"/>
where variable_name is the name of an existing variable that you want to use when executing the algorithm. The variable must be defined using a VarDef tag in a rule for the same object type that is specified in the parent AttributeValues tag.
If the variable definition does not exist for a variable that is referenced, an error is generated when the VarRef tag is evaluated.
Examples that Use Arg, Attr, Value, and VarRef Tags
The following sample XML that defines the GeneratedNumber variable uses the Arg tag to specify the sequence that is used in generating the number:
<VarDef id="GeneratedNumber"
algorithm=”com.ptc.windchill.enterprise.revisionControlled.server.impl.NumberGenerator">
<Arg>{GEN:wt.enterprise.SequenceGenerator:WTPARTID_seq:10:0}</Arg>
</VarDef>
In this example, the sequence generator returns a string value that is then used as the value for the GeneratedNumber variable.
In the following sample XML, the VarRef tag supplies the default value for the number attribute:
<AttrValue id=”number”>
<VarRef id=”GeneratedNumber”/>
</AttrValue>
The example assumes that the variable definition for GeneratedNumber is available through another rule (as shown in the previous example).
In the following sample XML, the EqualsTest algorithm requires two arguments. The first argument uses the Attr tag to evaluate the name attribute and the second argument uses the Value tag to specify the GetNullValue algorithm that returns a null value:
<Value algorithm="wt.rule.algorithm.EqualsTest">
<Attr id="name"/>
<Value algorithm="wt.rule.algorithm.GetNullValue"/>
</Value>
Was this helpful?