The ephox:if element takes a condition and evaluates it to be either true or false. If the condition is true, the contents of the ephox:if element are displayed through the view.
The following example shows how to use an XSD and XSL configuration to display a string element only if a specific checkbox element is selected.
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns="http://www.w3.org/2001/XMLSchema"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.ephox.com/example/dynamicif" xmlns:tns="http://www.ephox.com/example/dynamicif"
elementFormDefault="qualified">
<xsd:element name="dynamicif">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="question" type="xsd:boolean" default="true" />
<xsd:element name="subquestion" type="xsd:string" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema><?xml version="1.0" encoding="US-ASCII"?>
<xs:stylesheet xmlns:xs="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:my="http://www.ephox.com/example/dynamicif"
xmlns:ephox="http://www.ephox.com/product/editliveforxml/1.0">
<xs:template match="/">
<html>
<head>
<title>Dynamic If Example</title>
</head>
<body>
<h1>Dynamic If Example</h1>
<xs:apply-templates select="my:dynamicif" />
<p>End Test</p>
</body>
</html>
</xs:template>
<xs:template match="my:dynamicif">
<p><xs:value-of select="my:question" /> Show second question</p>
<ephox:if test="my:question = 'true'">
<p>Question 2: <xs:value-of select="my:subquestion" /></p>
</ephox:if>
<ephox:button action="xmlRemove" enabled="true" />
</xs:template>
</xs:stylesheet>Copyright 2001-2005 Ephox Corporation. All Rights Reserved.