String and Index Algorithm Examples
The following is an example rule XML fragment that uses the Substring default value algorithm to set the name attribute equal to the first 5 characters of the number attribute.
<AttrValue id=”name” algorithm=”wt.rule.algorithm.Substring”>
<Attr id=”number”/>
<Arg>0</Arg>
<Arg>5</Arg>
</AttrValue>
The following is an example rule XML fragment that uses the Substring and IndexOf algorithms to set the name of a CAD document equal to its CAD name with the extension removed:
<AttrValue id="name" algorithm="wt.rule.algorithm.Substring">
<Attr id="CADName"/>
<Arg>0</Arg>
<Value algorithm="wt.rule.algorithm.IndexOf">
<Attr id="CADName"/>
<Arg>.</Arg>
</Value>
</AttrValue>
The arguments that are used in this example are as follows:
The first argument uses the Attr tag to identify the original string (which, in this case, is an attribute).
The second argument uses the Arg tag to identify the index of the beginning character of the substring, where 0 is index of the first character in the original string.
The third argument uses the Value tag to determine the index of the character where the substring stops. Inside the Value tag is the IndexOf algorithm that requires two additional arguments that are used to produce the index needed.
This example assumes that there is only one period in the CAD document name that is before the file extension.
If a CAD document name could include multiple periods, you can use the LastIndexOf algorithm instead of IndexOf to strip the characters after the last period as follows:
<AttrValue id="name" algorithm="wt.rule.algorithm.Substring">
<Attr id="CADName"/>
<Arg>0</Arg>
<Value algorithm="wt.rule.algorithm.LastIndexOf">
<Attr id="CADName"/>
<Arg>.</Arg>
</Value>
</AttrValue>
Was this helpful?