You can use translation to define properties that represent a certain existing Claim. Such properties can then be used in an expression in your custom vocabulary file, or in a Context Engine Cartridge TCDL tag.
Procedure
- In your Web application, navigate to the location of your Context Engine machine configuration file:
- In a .NET Web application, go to lib\config\.
- In a Java Web application, go to WEB-INF/classes/.
- Open the Context Engine translators file, cwd_engine_conf.xml, for editing.
- In the file, follow the path
<context>, <resolvers>, <translation>, then <translators>.
- Within the
<translators> section, add a section for the vocabulary from which the Claim originates, for example, http or adf.
- Within this section, add a section for the new property you want to define, as follows:
<context>
<resolvers>
<translation>
<translators>
<adf>
<aspects>
<user>
<teenager>
<from>taf:foo:bar:quux</from>
</teenager>
</user>
where <teenager> is the property you want to define, and taf:foo:bar:quux is the Claim that provides the value for this property. That is, you translate the Claim taf:foo:bar:quux to the property user.teenager.
- Save and close cwd_engine_conf.xml.
- Create a new custom vocabulary file, if you do not already have one. Open your custom vocabulary file for editing.
- Create a new
property element in the relevant aspect (in this example, user) and set its attributes as follows:
| Attribute | Description |
|---|
name | The name of the property (in this example, ageGroup) |
type | The data type of the property (in this example, boolean) |
default | A default value for the property |
- Save and close your custom vocabulary file.
Results
You can now use your new property in an expression that defines another property:
<aspect name="user">
<properties>
<property name="mobileTeenager" type="boolean" value="user.teenager and device.mobile" />
</properties>
</aspect>
You can also use your new property in a TCDL tag:
<tcdl:if expression="user.teenager">
Special promotion for teenagers
</tcdl:if>