The XML format produced by XmlDumper is an XML representation of various internal Descriptors used by Drools Expert and only supports features up to 4.0<br><br>It is unfortunately not the same as that stored internally in Guvnor (which is simply a XStream representation of Guvnor's internal model).<br>
<br>Furthermore Guvnor's internal representation is private and subject to change from release to release.<br>
<br>There is no easy way to convert from one to the other, other than writing your own XSLT.<br><br>With kind regards,<br><br>Mike<br><br><div class="gmail_quote">On 29 May 2012 13:36, Anirban Bandyopadhyay <span dir="ltr"><<a href="mailto:Anirban.Bandyopadhyay@monitisegroup.com" target="_blank">Anirban.Bandyopadhyay@monitisegroup.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div link="blue" vlink="purple" lang="EN-GB">
<div>
<p class="MsoNormal"><span style="color:#1f497d">Hi,<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="color:#1f497d">We have a set of rule files in DRL format. We couldn’t find a way (tool) of importing them into Guvnor as BRL file so that we can edit using the designer.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="color:#1f497d">We ended up using the DrlParser and XmlDumper to transform them from DRL to BRL. It produces the XML and when we add it to the repository using WebDav, Guvnor lists the files under Business Rule which is perfect.
BUT when I try to open it, it throws the following error:<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="color:#c0504d">com.thoughtworks.xstream.converters.reflection.AbstractReflectionConverter$Unkno<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#c0504d">wnFieldException: No such field org.drools.ide.common.client.modeldriven.brl.Rul<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#c0504d">eModel.rule-attribute<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#c0504d">---- Debugging information ----<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#c0504d">field : rule-attribute<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#c0504d">class : org.drools.ide.common.client.modeldriven.brl.RuleModel<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#c0504d">required-type : org.drools.ide.common.client.modeldriven.brl.RuleModel<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#c0504d">converter-type : com.thoughtworks.xstream.converters.reflection.ReflectionC<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#c0504d">onverter<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#c0504d">path : /rule/rule-attribute<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#c0504d">version : null<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#c0504d">-------------------------------<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#c0504d"> at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConv<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#c0504d">erter.determineType(AbstractReflectionConverter.java:449)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#c0504d"> at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConv<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#c0504d">erter.doUnmarshal(AbstractReflectionConverter.java:290)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#c0504d"> at com.thoughtworks.xstream.converters.reflection.AbstractReflectionConv<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#c0504d">erter.unmarshal(AbstractReflectionConverter.java:230)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#c0504d"> at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshall<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#c0504d">er.java:72)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#c0504d"> at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(A<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#c0504d">bstractReferenceUnmarshaller.java:65)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#c0504d"> at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnm<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#c0504d">arshaller.java:66)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#c0504d"> at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnm<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#c0504d">arshaller.java:50)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#c0504d"> at com.thoughtworks.xstream.core.TreeUnmarshaller.start(TreeUnmarshaller<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#c0504d">.java:134)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#c0504d"> at com.thoughtworks.xstream.core.AbstractTreeMarshallingStrategy.unmarsh<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#c0504d">al(AbstractTreeMarshallingStrategy.java:32)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#c0504d"> at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:1035)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#c0504d"> at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:1019)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#c0504d"> at com.thoughtworks.xstream.XStream.fromXML(XStream.java:895)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#c0504d"> at com.thoughtworks.xstream.XStream.fromXML(XStream.java:886)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#c0504d"> at org.drools.ide.common.server.util.BRXMLPersistence.unmarshal(BRXMLPer<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#c0504d">sistence.java:191)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#c0504d"> at org.drools.guvnor.server.contenthandler.drools.BRLContentHandler.retr<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#c0504d">ieveAssetContent(BRLContentHandler.java:41)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#c0504d"> at org.drools.guvnor.server.RepositoryAssetService.handlePackageItem(Rep<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#c0504d">ositoryAssetService.java:132)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#c0504d"> at org.drools.guvnor.server.RepositoryAssetService.loadRuleAsset(Reposit<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#c0504d">oryAssetService.java:118)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#c0504d"> at org.drools.guvnor.server.RepositoryAssetService$Proxy$_$$_WeldClientP<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#c0504d">roxy.loadRuleAsset(RepositoryAssetService$Proxy$_$$_WeldClientProxy.java)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#c0504d"> at org.drools.guvnor.server.RepositoryServiceServlet.loadRuleAsset(Repos<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#c0504d">itoryServiceServlet.java:403)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#c0504d"> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#c0504d"> at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#c0504d">java:39)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#c0504d"> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#c0504d">sorImpl.java:25)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#c0504d"> at java.lang.reflect.Method.invoke(Method.java:597)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#c0504d"> at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:5<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#c0504d">69)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#c0504d"> at com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall(Remot<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#c0504d">eServiceServlet.java:208)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#c0504d"> at com.google.gwt.user.server.rpc.RemoteServiceServlet.processPost(Remot<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#c0504d">eServiceServlet.java:248)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#c0504d"> at com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet.doPost(Ab<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#c0504d">stractRemoteServiceServlet.java:62)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#c0504d"> at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#c0504d"> at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#c0504d"> at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#c0504d">icationFilterChain.java:290)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#c0504d"> at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#c0504d">ilterChain.java:206)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#c0504d"> at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#c0504d">alve.java:233)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#c0504d"> at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#c0504d">alve.java:191)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#c0504d"> at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#c0504d">ava:127)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#c0504d"> at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#c0504d">ava:102)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#c0504d"> at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#c0504d">ve.java:109)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#c0504d"> at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.jav<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#c0504d">a:293)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#c0504d"> at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcesso<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#c0504d">r.java:877)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#c0504d"> at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.pr<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#c0504d">ocess(Http11AprProtocol.java:594)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#c0504d"> at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:16<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#c0504d">75)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#c0504d"> at java.lang.Thread.run(Thread.java:662)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="color:#1f497d">I am able to re-produce the same error when I try to convert the BRL to DRL using BRDRLPersistence and BRXMLPersistence marshalling and unmarshalling. I checked that the field ‘rule-attribute’ is indeed not
present in org.drools.brms.client.modeldriven.brl.RuleModel. when I look at the example brl file from the sample mortgage, they don’t have ‘rule-attribute’, and it’s not only that specific node, the whole set of node names are different.
<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal">>>>>>>>>>>>>>>>>>>>>>>>>>>>><u></u> <u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">public void convertDrlToBrl() throws IOException, DroolsParserException {<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal"> Resource fileResource = new ClassPathResource("Beneficiary_User_KYC_Level_3_Daily_Limit.drl");<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal"> DrlParser parser = new DrlParser();<u></u><u></u></p>
<p class="MsoNormal"> XmlDumper dumper = new XmlDumper();<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal"> Reader source = new InputStreamReader(new FileInputStream(fileResource.getFile()));<u></u><u></u></p>
<p class="MsoNormal"> PackageDescr pkg = parser.parse(source);<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal"> String xmlString = dumper.dump(pkg);<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal"> System.out.println(xmlString);<u></u><u></u></p>
<p class="MsoNormal"> }<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal"><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<u></u> <u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><u></u> <u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal"> public void convertBrlToDrl() throws IOException {<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal"> Resource fileResource = new ClassPathResource("Beneficiary_User_KYC_Level_3_Daily_Limit_BRL.brl");<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal"> String fileAsString = FileUtils.readFileToString(fileResource.getFile());<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal"> BRDRLPersistence write = (BRDRLPersistence) BRDRLPersistence.getInstance();<u></u><u></u></p>
<p class="MsoNormal"> BRXMLPersistence read = (BRXMLPersistence) BRXMLPersistence.getInstance();<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal"> RuleModel ruleModel = read.unmarshal(fileAsString);<u></u><u></u></p>
<p class="MsoNormal"> String outputDRL = write.marshal(ruleModel);<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal"> System.out.println(outputDRL);<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal"> }<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal"><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<u></u> <u></u></p>
<p class="MsoNormal"><span style="color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="color:#1f497d">Generated xml file:<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal">===============================================<u></u><u></u></p>
<p class="MsoNormal"><span style="color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><rule name="Beneficiary_User_KYC_Level_3_Daily_Limit_BRL"><u></u><u></u></p>
<p class="MsoNormal"><rule-attribute name="dialect" value="mvel" /><u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal"><lhs><pattern object-type="UserBean" ><u></u><u></u></p>
<p class="MsoNormal"><field-constraint field-name="kycLevel"> <u></u><u></u></p>
<p class="MsoNormal"><literal-restriction evaluator="==" value="KYC_LEVEL_3" /><u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal"></field-constraint><u></u><u></u></p>
<p class="MsoNormal"><field-constraint field-name="userType"> <u></u><u></u></p>
<p class="MsoNormal"><literal-restriction evaluator="==" value="BENEFICIARY" /><u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal"></field-constraint><u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal"></pattern><u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal"><pattern object-type="Activity" ><u></u><u></u></p>
<p class="MsoNormal"><field-constraint field-name="type"> <u></u><u></u></p>
<p class="MsoNormal"><literal-restriction evaluator="!=" value="TRANSACTION.SEND" /><u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal"></field-constraint><u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal"></pattern><u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal"></lhs><rhs> Limit fact0 = new Limit();<u></u><u></u></p>
<p class="MsoNormal"> fact0.setType( "DAILY_TRANSACTION_LIMIT" );<u></u><u></u></p>
<p class="MsoNormal"> fact0.setValue( 10000 );<u></u><u></u></p>
<p class="MsoNormal"> fact0.setErrorMessage( "Maximum daily total amount of N10,000 exceeded for {0}." );<u></u><u></u></p>
<p class="MsoNormal"> insert(fact0 );<u></u><u></u></p>
<p class="MsoNormal"></rhs><u></u><u></u></p>
<p class="MsoNormal"></rule><u></u><u></u></p>
<p class="MsoNormal"><span style="color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="color:#1f497d">================================================<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="color:#1f497d">Am I doing something wrong? Is there a better way of converting the DRLs to BRLs?<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="color:#1f497d">Thanks in advance!<u></u><u></u></span></p>
<p class="MsoNormal"><b><span style="font-size:9.0pt;font-family:"Arial","sans-serif";color:#1f497d">Anirban Bandyopadhyay</span><span style="color:#00b050"><u></u><u></u></span></b></p>
</div>
<br>
<hr>
<font color="Gray" face="Arial" size="1">This message contains confidential and proprietary information of the sender, and is intended only for the person(s) to whom it is addressed. Any use, distribution, copying, disclosure or taking of any action in reliance
upon it by any other person is strictly prohibited. If you have received this message in error, please notify the e-mail sender immediately, and delete the original message without making a copy.<br>
<br>
The Monitise group comprises: Monitise plc (Reg. No. 6011822), Monitise Group Limited (Reg. No. 5590897), Monitise International Limited (Reg. No. 5556711) and Monitise Europe Limited (Reg. No. 4831976). These companies are registered in England and Wales and
their registered office address is: Warnford Court, 29 Throgmorton Street, London, EC2N 2AT United Kingdom.<br>
</font>
</div>
<br>_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
<br></blockquote></div><br>