sel:if

Purpose

Provides an alternative to using the sel:expr attribute alone when a selection condition applies to several elements. You can also use it to control processing a document fragment that does not have a single root element.

Note:

There is no sel:else element. Instead, the sel:select element and its children provide a way to choose between alternative content.

Contains

Attribute

Attribute Description Type Default Options Use
expr Determines whether or not the content is selected for processing. If the expression evaluates to 'true', the content is selected, otherwise it is not processed. If you omit the attribute the content is selected for processing by default. xs:string     optional 

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>sel:if</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>

Related topics