MCS 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. This section provides details of the functions available. 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').

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. This section provides details of the functions available. 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').

Namespaces

The mapping between the function namespaces and their prefixes is defaulted by the MCS expression processor, so that you do not need to supply namespace definitions in the XDIME document. However, if your XDIME includes an expression with a namespace definition, it is honored by the processor, allowing you to override the defaults if you wish.

device:

http://www.volantis.com/xmlns/mariner/device

pipeline:

http://www.volantis.com/xmlns/marlin-pipeline

mcs:

http://www.volantis.com/xmlns/2006/01/xdime/mcs

request:

http://www.volantis.com/xmlns/mariner/request

layout:

http://www.volantis.com/xmlns/mariner/layout

Name Alias Purpose
device:getAncestorRelationship device:relationship

Checks whether the named device is an ancestor of the current device. It is equivalent to the getAncestorRelationShip method of the MarinerRequestContext class. The return codes from that method are mapped to one of the returned values.

device:getDeviceName device:name

Returns the name of the requesting device.

device:getPolicyValue  

Used to access the value of a specific device policy for the current target device. If no value for the specified policy can be found, an empty sequence is returned. Otherwise the value of the policy is returned as a string.

device:isInstanceOf device:is-instance-of

Returns a boolean value indicating if the current device is an instance of the named device or one of its descendants in the hierarchy.

device:name-from-imei  

Returns the Antenna Device Repository device name that is associated with the given IMEI number.

device:policy-value  

Used to access the value of a specific device policy for the current target device. If no value for the specified policy can be found, an empty sequence is returned. Otherwise the value of the policy is returned. The type of the returned value is chosen based on the type of device policy.

layout:getPaneInstance  

Returns a reference to one instance of a pane inside an iterating format. The reference can be used wherever a pane name can be used.

layout:getRegionInstance  

Returns a reference to one instance of a region inside an iterating format. The reference can be used wherever a region name can be used.

mcs:feature  

Returns a boolean value indicating if the selected feature is supported on the current device.

pipeline:duration-to-seconds  

Converts an XML schema duration value or XML schema string representation of a duration into a number of seconds. Returns the equivalent number of seconds and fractions of a second, resolving the duration against the current datetime and timezone.

request:getCookieValue  

Used to access the value of a cookie when direct access to the original request is not available.

request:getHeader  

Used to access the value of a request header.

request:getHeaders  

Used to access the set of values of a request headers.

request:getParameter  

Used to access the value of a request parameter.

request:getParameters  

Used to access the set of values of a request parameter.

The '%' character and braces '{' and '}' must be used when a function expression specifies the value of an attribute on a selected tag.

<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/2002/06/xhtml2">
  <head>
    <title>MCS function expressions</title>
  </head>
  <body>
    <p><a href="test.xdime" title="%{device:policy-value('protocol')}">Protocol</a></p>
  </body>
</html>

Function expressions may also be used with conditional expressions. Refer to Selection elements and attributes for further information.

<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/2002/06/xhtml2"
  xmlns:sel="http://www.w3.org/2004/06/diselect">
  <head>
    <title>MCS function expressions</title>
  </head>
  <body>
    <sel:if expr="device:policy-value('supports.client.framework')='true'">
      <p>This device supports the Client Framework 1.</p>
    </sel:if>
    <sel:if expr="device:policy-value('supports.client.framework')='false'">
      <p>This device does not support the Client Framework 1.</p>
    </sel:if>
  </body>
</html>

Boolean operations

The following XPath boolean operations are supported:

=, >, >=, <, <=, !=, and, or, not

Casting operations

To cast values to the number type and compare values you can use the number() casting function, defined in XPath, for example:

number(device:getPolicyValue('pixelsy')) &gt;= 80

UAProf policy values

You can test whether or not a single item is contained within a device policy that is represented as a rdf:Bag or rdf:Seq element in UAProf documents. An example of such a policy is UAProf.CcppAcceptCharSet.

Related topics