是否允许嵌套'if'语句? 例如:
<if cond="1 == 1">
<if cond="2 == 2">
One is in fact equal to one and Two is in fact equal to two
<else/>
One is in fact equal to one but Two is never not equal to two
</if>
<else/>
One is never not equal to one
</if>
我意识到我可以使用'&&
'语句重写这个条件,但是我想要做的逻辑会变得混乱,以便继续重复if elseifs链条。
答案 0 :(得分:3)
是的,根据找到的架构定义here。 if
是executable.content
元素,允许包含零个或多个executable.content
元素的序列。
答案 1 :(得分:0)
添加@ John的答案(因为评论有字数限制):
对于VXML 2.1也是如此:https://www.w3.org/TR/voicexml21/vxml.xsd
<xsd:element name="if">
<xsd:sequence>
<xsd:group ref="executable.content" minOccurs="0" maxOccurs="unbounded"/>
<xsd:sequence minOccurs="0" maxOccurs="unbounded">
<xsd:element ref="elseif"/>
<xsd:group ref="executable.content" minOccurs="0" maxOccurs="unbounded"/>
</xsd:sequence>
<xsd:sequence minOccurs="0" maxOccurs="1">
<xsd:element ref="else"/>
<xsd:group ref="executable.content" minOccurs="0" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:sequence>
<xsd:attributeGroup ref="If.attribs"/>
</xsd:complexType>
</xsd:element>