Break example

hyeung
User offline. Last seen 1 year 44 weeks ago. Offline
Joined: 01/22/2010
Points: 30

I am new to EMML. I tired to break from a loop. I experimented with the code from the help file but failed.

First, it complained on variable 'cnt' not found. I added definition for cnt and it gave an error on: Unsuitable operands for arithmetic operation (xs:string, xs:integer)

Can someone teach me how to make this work?

Thanks.

 

<mashup xmlns:xsi= "http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://www.jackbe.com/2008-03-01/EMMLSchema/ ../src/schemas/EMMLSpec.xsd"
   xmlns="http://www.jackbe.com/2008-03-01/EMMLSchema"
   xmlns:macro="http://www.jackbe.com/2008-03-01/EMMLMacro"
   name = "looptest">
 <variables>
  <variable name="cnt" type="integer" />
 </variables> 
 <while condition="true()"> 
  <display message="while-loop: " expr="$cnt"/> 
  <assign fromexpr="$cnt + 1" outputvariable="cnt"/> 
  <if condition="$cnt > 10">   
   <display message="enough already..." /> 
   <break/>
  </if>
 </while>
</mashup>

0
Your rating: None
smitchell
smitchell's picture
User offline. Last seen 7 hours 51 min ago. Offline
Joined: 08/29/2008
Points: 34

I think the last error has to do with your definition of the cnt variable. Integer is not a valid datatype for EMML variables, so the Mashup Engine is treating it as a string. Valid variable types are string, number, date, boolean and document (meaning complex object and well-formed XML document).

So change this to:

<variable name="cnt" type="number"/>

and it should work.

<!--Session data-->

 

Sara, technical writer/jackbe

 

hyeung
User offline. Last seen 1 year 44 weeks ago. Offline
Joined: 01/22/2010
Points: 30

Thanks. No, I still got:  Unsuitable operands for arithmetic operation (xs:string, xs:integer) : EMML Line # : 9

raj
raj's picture
User offline. Last seen 1 week 4 days ago. Offline
Joined: 09/22/2008
Points: 4

Hi,

This seems a bug. The workaround is to initialize the 'cnt' variable explcitly i.e.,

<variable name="cnt" type="integer" default="0" />

Now, the output should be as ...

    [java] while-loop:     0
     [java] while-loop:     1.0
     [java] while-loop:     2.0
     [java] while-loop:     3.0
     [java] while-loop:     4.0
     [java] while-loop:     5.0
     [java] while-loop:     6.0
     [java] while-loop:     7.0
     [java] while-loop:     8.0
     [java] while-loop:     9.0
     [java] while-loop:     10.0
     [java] enough already...   
 

 

raj.  chief masher @ jackbe

hyeung
User offline. Last seen 1 year 44 weeks ago. Offline
Joined: 01/22/2010
Points: 30

Thanks, raj. It works now!

 

mpriest
User offline. Last seen 1 year 48 weeks ago. Offline
Joined: 03/02/2010
Points: 0

I was having a similar problem. Thanks!