MCS expressions

MCS expressions allow additional information to be transmitted to various parts of MCS, such as its tags and layouts. The major area to exploit MCS expressions is the use of policies and variants. In this use, the MCS expression used evaluates to a particular variant used to provide the data for the attribute.

MCS expressions allow additional information to be transmitted to various parts of MCS, such as its tags and layouts. The major area to exploit MCS expressions is the use of policies and variants. In this use, the MCS expression used evaluates to a particular variant used to provide the data for the attribute.

Note:

Unless otherwise stated, audio (.mauc), link (.mlnk), rollover image (.mdyv) and text (.mtxt) policies are not supported in XDIME 2.

Expression syntax

In XDIME 1, MCS expressions are distinguished from regular literals by being enclosed in scope delimiting braces '{' and '}'. Because policy names will often be the sole contents of MCS expressions, you can use the shorthand form {/[policyName].[fileExtension]} whenever an attribute value could be either a text literal or a policy reference.

<?xml version="1.0" encoding="UTF-8"?>
<canvas layoutName="/welcome.mlyt" pageTitle="img">
  <pane name="logo">
    <img src="/welcome/vol_logo.mimg" alt="{/altText.mtxt}"/>
  </pane>
</canvas>

Contrast the use of the alt attribute with the next example, where the attribute has a literal value.

<?xml version="1.0" encoding="UTF-8"?>
<canvas layoutName="/welcome.mlyt" pageTitle="img">
  <pane name="logo">
    <img src="/welcome/vol_logo.mimg" alt="Antenna Software, Inc. Logo"/>
  </pane>
</canvas>

Please note that in XDIME 2 the object element can be used to display the contents of a text policy.

<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/2002/06/xhtml2">
  <head>
    <title>Text policy</title>
  </head>
  <body>
    <p>
      <object src="/simpleText.mtxt"/>
    </p>
  </body>
</html>

Escaping complete attributes

MCS generally uses the '\' character to escape its scope delimiters. However, because JSP also uses this character, a pair of back slashes must be used.

The following statement contains a MCS expression that results in a policy name being used as the value of the myparm attribute.

<sometag myparm="{/mypolicy.mtxt}">

To escape this value, so that the literal text of the entire attribute is passed as a parameter, you would use the following syntax.

<sometag myparm="\\{/mypolicy.mtxt\\}">

Function expressions

MCS function expressions provide access to information from a variety of sources, including the current HTTP request and the device repository. They can be used to evaluate, for example, the name of pane to which output is to be sent during page generation. Function expressions are identified by name that consists of namespace prefix and local name, and have a structure and syntax similar to that used in XPath 2.0 functions, for example request:getParameter('id'). Refer to MCS function expressions for further information.

Related topics