<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">

<head>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 12 (filtered medium)">
<title>Smooks and Drools Pipeline</title>
<style>
<!--
 /* Font Definitions */
 @font-face
        {font-family:Wingdings;
        panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p
        {mso-style-priority:99;
        mso-margin-top-alt:auto;
        margin-right:0cm;
        mso-margin-bottom-alt:auto;
        margin-left:0cm;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
span.EmailStyle18
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page Section1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.Section1
        {page:Section1;}
 /* List Definitions */
 @list l0
        {mso-list-id:2117098274;
        mso-list-template-ids:-1000724504;}
@list l0:level1
        {mso-level-number-format:bullet;
        mso-level-text:\F0B7;
        mso-level-tab-stop:36.0pt;
        mso-level-number-position:left;
        text-indent:-18.0pt;
        mso-ansi-font-size:10.0pt;
        font-family:Symbol;}
ol
        {margin-bottom:0cm;}
ul
        {margin-bottom:0cm;}
-->
</style>
<!--[if gte mso 9]><xml>
 <o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
 <o:shapelayout v:ext="edit">
  <o:idmap v:ext="edit" data="1" />
 </o:shapelayout></xml><![endif]-->
</head>

<body lang=EN-CA link=blue vlink=purple>

<div class=Section1>

<p><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>Hey guys
(Drools newbie here)</span> <o:p></o:p></p>

<p><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>I'm
*attempting* to use the Drools/Smooks pipeline functionality to insert facts
into my knowledgebase and I'm having a little trouble figuring out exactly how
to do this. I've read the API docs for the 5.0.0.M5 and looked at the test
cases but I guess I'm still not quite getting it, so I'm hoping someone here
can point me in the right direction.</span><o:p></o:p></p>

<p><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>I've got an
XML file defined basically like this:</span> <o:p></o:p></p>

<p><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>&lt;submission&gt;</span>
<br>
<span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>&nbsp;&nbsp;
&lt;facility&gt;</span> <br>
<span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&lt;faccode&gt;xxx&lt;/faccode&gt;</span> <br>
<span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>&nbsp;&nbsp;
&lt;/facility&gt;</span> <br>
<span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>&nbsp;&nbsp;
&lt;lineitem&gt;</span> <br>
<span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&lt;acctcode&gt;xxxx&lt;/acctcode&gt;</span> <br>
<span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&lt;amount&gt;999&lt;/amount&gt;</span> <br>
<span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>&nbsp;&nbsp;
&lt;lineitem&gt;</span> <br>
<span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>&nbsp;&nbsp;
&lt;lineitem&gt;</span> <br>
<span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&lt;acctcode&gt;xxxx&lt;/acctcode&gt;</span> <br>
<span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&lt;amount&gt;999&lt;/amount&gt;</span> <br>
<span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>&nbsp;&nbsp;
&lt;lineitem&gt;</span> <br>
<span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>&lt;submission&gt;</span>
<o:p></o:p></p>

<p><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>Within the
XML file, there is 1 and only 1 &quot;facility&quot; node and multiple
&quot;lineitem&quot; nodes. I'd like to use the DroolsSmooks pipleline
functionality to use Smooks to insert 1 &quot;facility&quot; fact and multiple
&quot;lineitem&quot; facts into my knowledgbase.</span><o:p></o:p></p>

<p><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>The code
I've written to do this is similar to the following (taken from sample test
code I've seen in the Drools source):</span><o:p></o:p></p>

<p style='margin-left:36.0pt'><span style='font-size:10.0pt;font-family:"Courier New"'>StatefulKnowledgeSession
ksession = kbase.newStatefulKnowledgeSession();</span> <br>
<span style='font-size:10.0pt;font-family:"Courier New"'>Action
executeResultHandler = PipelineFactory.newExecuteResultHandler();</span> <br>
<span style='font-size:10.0pt;font-family:"Courier New"'>KnowledgeRuntimeCommand
insertStage = PipelineFactory.newStatefulKnowledgeSessionInsert();</span> <br>
<span style='font-size:10.0pt;font-family:"Courier New"'>insertStage.setReceiver(executeResultHandler);</span>
<br>
<span style='font-size:10.0pt;font-family:"Courier New"'>Smooks smooks = new
Smooks(&quot;smooks-config.xml&quot;);</span> <br>
<span style='font-size:10.0pt;font-family:"Courier New"'>Transformer
transformer = PipelineFactory.newSmooksFromSourceTransformer(smooks,
&quot;root&quot;);</span> <br>
<span style='font-size:10.0pt;font-family:"Courier New"'>transformer.setReceiver(insertStage);</span>
<br>
<span style='font-size:10.0pt;font-family:"Courier New"'>Pipeline pipeline =
PipelineFactory.newStatefulKnowledgeSessionPipeline(ksession);</span> <br>
<span style='font-size:10.0pt;font-family:"Courier New"'>pipeline.setReceiver(transformer);</span>
<br>
<span style='font-size:10.0pt;font-family:"Courier New"'>ResultHandlerImpl
resultHandler = new ResultHandlerImpl();</span> <br>
<span style='font-size:10.0pt;font-family:"Courier New"'>pipeline.insert(ResourceFactory.newClassPathResource(&quot;submission.xml&quot;),
resultHandler );</span> <o:p></o:p></p>

<p><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>While
stepping through the above code, the last line returns an NPE. I've tried
playing with the &quot;Transformer transformer - PipeLineFactory&#8230;&quot; line,
substituting &quot;root&quot; for something else and it goes into an infinite
loop. What is the purpose of the &quot;root&quot; value being set in this line?</span><o:p></o:p></p>

<p><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>Can anyone
tell me if I'm even on the right track here, or am I misunderstanding what the
Smooks data loader can do for me?</span><o:p></o:p></p>

<p><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>Regards, <o:p></o:p></span></p>

<p><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Dave<o:p></o:p></span></p>

</div>

</body>

</html>