2013-03-28 2 views

답변

4

가이 동작을 구현하는 쉬운 방법은 없지만, 아마도 다음과 같은 제안이 도움이 될 것입니다 .

  • 상기 for task (즉,하지의 foreach)를 사용
  • 스킵해야 할 항목이 실패되도록하는 조건으로 fail task를 사용 사실
  • keepgoing 특성을 설정. Letter a Letter b


    : 당신이 출력 될 것입니다 당신이

    <for list="a,b,c,d,e" param="letter" keepgoing="true"> 
        <sequential> 
         <if> 
         <equals arg1="@{letter}" arg2="c" /> 
         <then> 
         <property name="myBreakProperty" value="nevermind the value"/> 
         </then> 
        </if> 
        <fail if="myBreakProperty"/> 
        <echo>Letter @{letter}</echo> 
        </sequential> 
    </for> 
    

    을 깰 필요가 감지 할 때마다 속성 myBreakProperty을 정의하여 휴식 뭔가를 얻을 수 있습니다


cont와 같은 것을 얻으려면 inue :

<for list="a,b,c,d,e" param="letter" keepgoing="true"> 
    <sequential> 
     <if> 
     <equals arg1="@{letter}" arg2="c" /> 
     <then> 
     <fail/> 
     </then> 
    </if> 
    <echo>Letter @{letter}</echo> 
    </sequential> 
</for> 

출력은 다음과 같습니다 Letter a Letter b Letter d Letter e

+0

감사합니다! 그게 효과가 있었어. –

1

당신이 실패로 가혹한 일을 실행하지 않고 휴식 프로세스 흐름을 만들 수 있습니다. 속성을 사용하여 휴식을 취할 때를 감지하면 다음과 같이 구현할 수 있습니다.

<var name="break.flag" unset="true"/> 

<for list="a,b,c,d,e" param="letter"> 
    <sequential> 
     <if> 
      <not> 
       <isset property="break.flag"/> 
      </not> 
     <then> 
      <if> 
       <equals arg1="@{letter}" arg2="c" /> 
      <then> 
       <property name="break.flag" value="true"/> 
      </then> 
      </if> 

      <if> 
       <not> 
        <isset property="break.flag"/> 
       </not> 
      <then> 
       <echo>Letter @{letter}</echo> 
       <echo>Do the rest of the loop here</echo> 
      </then> 
      </if> 
     </then> 
     </if> 
    </sequential> 
</for> 
+0

코드가 작동하지 않습니다. 플래그가 안타를 때 플래그를 해제해야합니다. – sloven

관련 문제