【问题标题】:ant xmltask node ifant xmltask 节点 if
【发布时间】:2014-07-07 11:25:33
【问题描述】:

我的新问题是 if 条件标签。

实际上,当“param”为0时,我无法进入条件“then”。

<xmltask source="rapport.xml">                                      
    <call path="//testsuites">
        <param name="chaine" path="@name"/>
        <param name="testsuite1" path="testsuite[1]/@name"/>
        <param name="testsuite2" path="testsuite[2]/@name"/>                                
        <param name="ko1" path="count(testsuite[1]/testcase/failure[@type='ko'])"/>
        <actions>   
            <echo message="count fichiers ko 1 : @{ko1}"/>
            <if>
                <equals arg1="${ko1}" arg2="0" />
                <then>
                    <echo message="OK"/>
                </then>
                <else>                              
                    <echo message="KO"/>                            
                </else>
            </if>                           
        </actions>
    </call>                               
</xmltask>

为什么我不能进入 "then" 条件,而只能进入 "else" while "arg1" = 0 ?

rapport.xml 是:

<testsuites name="COMPTES" tests="6" time="7" timestamp="2014-07-01T17-20-07" failures="6" errors="0">
    <testsuite name="100" tests="6" failures="6" errors="0" time="7">
        <testcase classname="Script.COMPTES.100" name="TEST1" time="1">
            <failure message="Not exist file or counter or used" type="fichiersInexistants">
                File No matches
            </failure>
        </testcase>
        <testcase classname="Script.COMPTES.100" name="TEST2" time="2">
            <failure message="Not exist file or counter or used" type="fichiersUtilises">
                Data set in use
            </failure>
        </testcase>
        <testcase classname="Script.COMPTES.100" name="TEST3" time="3">
            <failure message="Not exist file or counter or used" type="fichiersInexistants">
                File No matches
            </failure>
        </testcase>
        <testcase classname="Script.COMPTES.100" name="TEST4" time="3">
            <failure message="File abended" type="abended">
                File abended
            </failure>
        </testcase>
    </testsuite>
</testsuites>

【问题讨论】:

  • 向我们展示您的 XML 源意味着 rapport.xml
  • Manouti 的回答是正确的。请参阅 xmltask 文档 => oopsconsultancy.com/software/xmltask => “注意在此示例中如何取消引用参数(使用 @{...})。另请注意,对于嵌入式操作,每个属性都必须分配一个值。如果有疑问,请使用 指令中的默认属性。"

标签: xml if-statement ant ant-contrib xmltask


【解决方案1】:

尝试使用@{ko1} 而不是${ko1} 来引用参数。如果echo 真的在打印0,它应该可以工作。

<echo message="count fichiers ko 1 : @{ko1}"/>
<if>
    <equals arg1="@{ko1}" arg2="0" />

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-11
    • 1970-01-01
    • 2017-03-30
    • 1970-01-01
    • 2015-07-31
    • 1970-01-01
    相关资源
    最近更新 更多