<group> not working

polly
User offline. Last seen 2 years 7 weeks ago. Offline
Joined: 02/12/2009
Points: 150

 I am not able to get a basic <group> to work on an xml result.

Here's the result;

 

<xml>   <item>     <logdate>2009-01-07</logdate>     <channel>Web</channel>   </item>   <item>     <logdate>2009-01-07</logdate>     <channel>Mail</channel>   </item>   <item>     <logdate>2009-01-09</logdate>     <channel>Web</channel>   </item>   <item>     <logdate>2009-01-09</logdate>     <channel>Mail</channel>   </item>   <item>     <logdate>2009-01-10</logdate>     <channel>Mail</channel>   </item> </xml> Here's the emml - both ways give the error below: <group outputvariable="groupResult" by="$result/xml/item/channel"> </group> <group outputvariable="groupResult" by="$result//item/channel"> </group>   Executing the Script in Debug Mode...   Connecting to the Debugger... Connecting to the Debugger... Connecting to the Debugger... Executing the script...  2009-03-28 15:52:20,572 ERROR [com.jackbe.jbp.sas.sg.controller.RESTPayloadBuilder] - <no input="" arguments="" found="" for="" operationid="getData"> 2009-03-28 15:52:24,631 ERROR [com.jackbe.jbp.jems.moe.runtime.JEMSDesignerImpl] - <error execution="" mashup="" script="" null="" emml="" line=""> java.lang.RuntimeException: null : EMML Line # : 23 at com.jackbe.jbp.jems.moe.runtime.MolInterpreter.execute(MolInterpreter.java:156) at com.jackbe.jbp.jems.moe.runtime.JEMSDesignerImpl.executeWithParams(JEMSDesignerImpl.java:599) at com.jackbe.jbp.jems.moe.runtime.debugger.JEMSDebuggerImpl.resume(JEMSDebuggerImpl.java:76) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at com.jackbe.jbp.jems.moe.runtime.debugger.tpt.WorkerThread.invokeMethodAndPostResponse(WorkerThread.java:84) at com.jackbe.jbp.jems.moe.runtime.debugger.tpt.WorkerThread.requestRecd(WorkerThread.java:77) at com.jackbe.jbp.jems.moe.runtime.debugger.tpt.WorkerThread.run(WorkerThread.java:49) Caused by: java.lang.NullPointerException at com.jackbe.jbp.jems.moe.commons.DOMUtils.cleanupElements(DOMUtils.java:1088) at com.jackbe.jbp.jems.moe.ast.OpGroup.getBody(OpGroup.java:43) at com.jackbe.jbp.jems.moe.runtime.commands.GroupCommand.buildGroupQuery(GroupCommand.java:106) at com.jackbe.jbp.jems.moe.runtime.commands.GroupCommand.execute(GroupCommand.java:75) at com.jackbe.jbp.jems.moe.runtime.commands.AbstractCommand.callExecute(AbstractCommand.java:62) at com.jackbe.jbp.jems.moe.runtime.MolInterpreter.execute(MolInterpreter.java:153) ... 9 more java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at com.jackbe.jbp.jems.moe.runtime.debugger.tpt.WorkerThread.invokeMethodAndPostResponse(WorkerThread.java:84) at com.jackbe.jbp.jems.moe.runtime.debugger.tpt.WorkerThread.requestRecd(WorkerThread.java:77) at com.jackbe.jbp.jems.moe.runtime.debugger.tpt.WorkerThread.run(WorkerThread.java:49) Caused by: com.jackbe.jbp.sas.saf.common.exception.JBPException: Error execution Mashup Script : null : EMML Line # : 23 at com.jackbe.jbp.jems.moe.runtime.JEMSDesignerImpl.executeWithParams(JEMSDesignerImpl.java:612) at com.jackbe.jbp.jems.moe.runtime.debugger.JEMSDebuggerImpl.resume(JEMSDebuggerImpl.java:76) ... 7 more Caused by: java.lang.RuntimeException: null : EMML Line # : 23 at com.jackbe.jbp.jems.moe.runtime.MolInterpreter.execute(MolInterpreter.java:156) at com.jackbe.jbp.jems.moe.runtime.JEMSDesignerImpl.executeWithParams(JEMSDesignerImpl.java:599) ... 8 more Caused by: java.lang.NullPointerException at com.jackbe.jbp.jems.moe.commons.DOMUtils.cleanupElements(DOMUtils.java:1088) at com.jackbe.jbp.jems.moe.ast.OpGroup.getBody(OpGroup.java:43) at com.jackbe.jbp.jems.moe.runtime.commands.GroupCommand.buildGroupQuery(GroupCommand.java:106) at com.jackbe.jbp.jems.moe.runtime.commands.GroupCommand.execute(GroupCommand.java:75) at com.jackbe.jbp.jems.moe.runtime.commands.AbstractCommand.callExecute(AbstractCommand.java:62) at com.jackbe.jbp.jems.moe.runtime.MolInterpreter.execute(MolInterpreter.java:153) ... 9 more  </error></no>

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

Hi,

looks like you are missing the group-by output.

Here is a sample using your dataset...

Sample output:

<itemstats>
   <item cnt="3" name="Mail"/>
   <item cnt="2" name="Web"/>
</itemstats>
 

EMML Script:     
        <output name="result" type="document" />
        <input name="payload" type="document">
<xml>
  <item>
    <logdate>2009-01-07</logdate>
    <channel>Web</channel>
  </item>
  <item>
    <logdate>2009-01-07</logdate>
    <channel>Mail</channel>
  </item>
  <item>
    <logdate>2009-01-09</logdate>
    <channel>Web</channel>
  </item>
  <item>
    <logdate>2009-01-09</logdate>
    <channel>Mail</channel>
  </item>  
  <item>   
    <logdate>2009-01-10</logdate>
    <channel>Mail</channel>
  </item>
</xml>
        </input>

        <group outputvariable="result" by="$payload/xml/item/channel">
            <itemstats>
                <item name="{$group_key}" cnt="{count(channel)}" />
            </itemstats>
        </group>
 

raj.  chief masher @ jackbe

polly
User offline. Last seen 2 years 7 weeks ago. Offline
Joined: 02/12/2009
Points: 150

Cheers Raj. Mark 

snhal
User offline. Last seen 2 years 41 weeks ago. Offline
Joined: 03/26/2009
Points: 101

hi Raj, thanks a lot for the input but if the input is <input name="payload" type="text" /> <xml><item></item><logdate></logdate>2009-01-07 <channel></channel>Web <item></item><logdate></logdate>2009-01-07 <channel></channel>Mail <item></item><logdate></logdate>2009-01-09 <channel></channel>IVR <item></item><logdate></logdate>2009-01-09 <channel></channel>Mail <item></item><logdate></logdate>2009-01-10 <channel></channel>Mail </xml>And if the expected out is like this then what changes are required ? <itemstats></itemstats><item></item><logdate></logdate>2009-01-07 <mail></mail>1 <web></web>1 <ivr></ivr>0 <item></item><logdate></logdate>2009-01-09 <mail></mail>0 <web></web>1 <ivr></ivr>1 <item></item><logdate></logdate>2009-01-09 <mail></mail>1 <web></web>0 <ivr></ivr>0 also mark thanks for taking intrest in my problem can you also help me find the list of commands like group and other such commands? is it documented anywhere ?

smitchell
smitchell's picture
User offline. Last seen 13 hours 19 min ago. Offline
Joined: 08/29/2008
Points: 34

You can use <foreach> to iterate through your input structure and then use <appendresult> to create the expected result. Both of these EMML statements -- and all of EMML -- are documented and many of the doc topics have examples. You can find this in Mashup Studio help (if you are using Eclipse). Or from the Presto doc site go to:

http://www.jackbe.com/prestodocs/v2.6.1/prestolibrary/index.html

Then search for EMML reference. The very first hit you should find is the 'EMML Reference' topic. This lists all the EMML statements (in alpha order) with links to the individual statements.

I would also *strongly* recommend looking through the 'Creating a Mashup Script' topic. This has all the basic steps -- but all of the EMML statements are also linked within general categories based on their effect, such as transform data, invoke SQL, control mashup flow and so on. This topic is another way to quickly find an EMML statement that "does something" if you're not familiar with the language.

Sara, technical writer/jackbe