device:policy-value

Purpose

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.

Signature

device:policy-value(policy as xs:string) as xs:any

Parameter

Name Description Type Use
policy The device policy whose value is to be returned. Valid values for this parameter are the names of device policies used in MCS APIs. An empty sequence or empty string results in an empty sequence being returned. xs:string required 

Example

<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/2002/06/xhtml2"
  xmlns:pipeline="http://www.volantis.com/xmlns/marlin-pipeline">
  <head>
    <title>device:policy-value</title>
  </head>
  <body>
    <p>Usable width: <pipeline:value-of expr="device:policy-value('pixelsx')"/></p>
  </body>
</html>

true() and false() can be used to evaluate boolean policies, for example:

<?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>device:policy-value</title>
  </head>
  <body>
    <sel:select>
      <sel:when expr="device:policy-value('javascript') = true()">
        <p>This device supports JavaScript.</p>
      </sel:when>
      <sel:otherwise>
        <p>This device does not support JavaScript.</p>
      </sel:otherwise>
    </sel:select>
  </body>
</html>

If a policy provides a list of values (either ordered or unordered) and there is more than one value specified for the target device, then the function can return all the values or only the selected one, for example:

<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/2002/06/xhtml2"
  xmlns:pipeline="http://www.volantis.com/xmlns/marlin-pipeline"
  xmlns:dco="http://www.w3.org/2004/06/diselect">
  <head>
    <title>device:policy-value</title>
  </head>
  <body>
    <p><pipeline:value-of expr="device:policy-value('UAProf.CcppAccept')"/></p>
    <p><pipeline:value-of expr="device:policy-value('UAProf.CcppAccept')[1]"/></p>
    <p><pipeline:value-of expr="device:policy-value('UAProf.CcppAccept')[2]"/></p>
  </body>
</html>

Related topics