Reusing existing Claims through translation

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

  1. 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/.
  2. Open the Context Engine translators file, cwd_engine_conf.xml, for editing.
  3. In the file, follow the path <context>, <resolvers>, <translation>, then <translators>.
  4. Within the <translators> section, add a section for the vocabulary from which the Claim originates, for example, http or adf.
  5. 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.

  6. Save and close cwd_engine_conf.xml.
  7. Create a new custom vocabulary file, if you do not already have one. Open your custom vocabulary file for editing.
  8. Create a new property element in the relevant aspect (in this example, user) and set its attributes as follows:
    AttributeDescription
    nameThe name of the property (in this example, ageGroup)
    typeThe data type of the property (in this example, boolean)
    defaultA default value for the property
  9. 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>