Using load() method for XML data at runtime

23 views
Skip to first unread message

Tony Amos

unread,
Sep 1, 2017, 4:17:37 PM9/1/17
to OpenRules


I would like to load data for a Business Concept at run time by passing in the path to a compliant XML file. I assume I can use the load API call as shown on page 107 of the user manual and in the HelloXMLPeople project, but I am missing something.

I created a Rules.xls with this environment:



And added the following WaterfallModel.xml file to my classpath:

<WaterfallModel >
<Hurdles type="Array of Hurdle(s)">
<Hurdle id="0" name="" annualReturn="0.0"/>
</Hurdles>
<Investors type="Array of Investor(s)">
<Investor type="Array of Equity(s)" id="0" name="" note="">
<Equity hurdleId="0" share="0.0"/>
</Investor>
</Investors>
<CashFlows type="Array of CashFlow(s)">
<CashFlow period="0" amount="0.00"/>
</CashFlows>
</WaterfallModel>


Then I added the following method to my xls file:



After the call to load() I will run the decisions, but this is for testing right now. When I call this method I want to pass in the name of the XML file containing the real data to evaluate, but when I open the engine I get the following error:


So I added Datatypes and a Glossary like so:




Now I get a bit further, but here is the error:



Now I suspect that I may be headed down the wrong path so I am looking for guidance. I'm confused since the HelloXMLPeople project doesn't have a Glossary or and Datatypes defined and I don't know where to go next.

My ultimate goal is to be able to pass XML data into the Decision at run-time for processing. If someone can point me toward a project or documentation on this, or provide commentary, I would appreciate it.

Thanks in advance.

Auto Generated Inline Image 1
Auto Generated Inline Image 2
Auto Generated Inline Image 3
Auto Generated Inline Image 4
Auto Generated Inline Image 5
Auto Generated Inline Image 6

OpenRules Support

unread,
Sep 1, 2017, 4:32:12 PM9/1/17
to OpenRules
Tony,

We don't know the exact structure of your project, but it seems that the first error "Type WaterfallModel not found" is your actual problem. Please replace "classpath:/data/WaterfallModel.xml" to ""file:../data/WaterfallModel.xml" in your Environment table. Here we assume that your folder "data" is at the same level as the folder "rules". Let us know about the results.

Support

Tony Amos

unread,
Sep 4, 2017, 8:04:26 PM9/4/17
to OpenRules
Thank you for the quick feedback. You assumed correctly about my project structure. I tried changing the classpath reference to a file reference, but then the file wouldn't be found unless I included the entire directory path. I set it back to classpath and moved on. When I put my data directory in the classpath, that made the difference. So you were right, the XML file was not found. The next error I got was that the WaterfallModel was already defined - which I had seen already when I used the file reference with the full path to the XML file (yes, an aha! moment). So I removed the Data definitions and it worked as I had hoped.

Thanks for your help and guidance.

Tony
Reply all
Reply to author
Forward
0 new messages