IF...THEN...ELSE 使用 XML [英] IF...THEN...ELSE using XML
问题描述
我有一个程序,它使用 XML 格式的规则为运行时创建可执行代码.我必须使用我自己的方言来定义一些动作和逻辑结构.我有 OR、AND 和 NOT 结构,现在我需要实现 IF..THEN..ELSE.
I have a program that uses XML formatted rules to create executable code for run-time. I have to define some actions and logical constructs using my own dialect. I have OR, AND, and NOT constructs and now I need to implement IF..THEN..ELSE.
我正在尝试提出一种有意义的语法,这是我目前所拥有的:
I'm trying to come up with a syntax that would make sense and here's what I have so far:
<IF id='if-1'>
<TIME from="5pm" to="9pm" />
</IF>
<THEN id='if-1'>
<...some actions defined.../>
</THEN>
<ELSE id='if-1'>
<...other set of actions defined here.../>
</ELSE>
If 对我来说很难读懂,但我没有看到一种更简洁的方式来表示它而不做太多嵌套.有人有建议吗?(此时不使用 XML 不是一种选择 :) )
If looks difficult to read to me, but I don't see a cleaner way to represent this without doing too much nesting. Does anyone have a suggestion? (not using XML is not an option at this point in time :) )
推荐答案
我个人认为 if/then/else 需要以某种方式链接起来.
I personally think that the if/then/else needs to be linked somehow.
<IF something>
<some actions>
<THEN something>
<some actions>
</THEN>
<ELSE something>
<some actions>
</ELSE>
</IF>
这篇关于IF...THEN...ELSE 使用 XML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!