comparison表达

comparison表达式实现了表达序列的简单条件选择。它具有以下一般形式:

 ... ... ... ... 

请注意,与其他表达不同,参数由名称而不是按位置标识。名称不是可选的,并且参数的顺序无关紧要。所有参数/属性都是可选的。这expr.属性默认为字符串'=',但所有其他属性和参数默认为空字符串“”。

这meaning of thecomparisonexpr.ession is to perform a simple conditional choice. The arguments/attributes ‘lhs’ and ‘rhs’ are abbreviations for ‘left-hand side’ and ‘right-hand side’. These two expressions are evaluated and compared. The comparison type is determined by the ‘expr’ attribute. If theexpr.attribute is ‘=’ and the comparison is true (that is, if the left hand side is equal to the right hand side), then the成功argument is evaluated and returned, otherwise the失败argument is evaluated and returned. If the expr attribute is ‘!=’, for ‘not equal’, then the sense of the comparison is reversed; i.e. if the comparison is true, then失败评估,否则成功is evaluated.

Note:This is not aflow-of-control条件表达式,而只是简单地选择在表达式参数之间进行评估。

这example below demonstrates a case in which news articles are tagged with their source language, ‘fr’ for ‘French’ and ‘en’ for English. Suppose that we want to extract all the author’s names, one per feature. But since the french word for ‘name’ is ‘nom’ (and ‘histoire’ for ‘story’), we want to selectively extract the author’s name based on the stories source language. We do this by assigning an attribute to a feature, and setting that attribute’s value as a comparison expression that chooses based on the ‘lang’ attribute.

Example

Stories.xml.xml.

<?XML Version =“1.0”编码=“UTF-8”?> <条目> <条目lang =“en”>  mark   ...    jean-sebastian   ...   

stories.xmp

        <!-- Here we check if the ‘lang’ attribute is equal to the string ‘Name’ and if it is, we extract the Name element. Otherwise, we extract the Nom element -->                
==========================================构造的功能|通知| +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |通知|通知|功能类型:`ression'|通知|属性(字符串):`作者'具有值`mark'|通知|通知|属性(字符串):`xml_type'有值`xml_no_geom'|通知|几何类型:未知(0)| |通知| ============================================================= |通知| +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | INFORM |功能类型:'进入” | INFORM |属性(字符串):“作者”有值`jean-sebastian'|通知|属性(字符串):`xml_type'具有值`xml_no_geom'|通知|几何类型:未知(0)|通知| =============================================================.