编写Drools决策表时请注意使用双引号

发布者:    |      

这是我在使用OpenOffice编写决策表时遇到的一个小问题

假设在条件列中,你想编写以下模式

section : Section(type == "$param") from company.sectionList

如果你将此输入到列中(不使用剪切/粘贴),它看起来会像这样

section : Section(type == “$param”) from company.sectionList 

这里的区别是OpenOffice生成的双引号 。如果你不更改它们并尝试使用例如

KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
DecisionTableConfiguration config = KnowledgeBuilderFactory.newDecisionTableConfiguration();
config.setInputType(DecisionTableInputType.XLS);
kbuilder.add(ResourceFactory.newClassPathResource("mydecisiontable.xls"), ResourceType.DTABLE, config);
.....

加载你的决策表,你会得到以下类型的异常

[8,29]: [ERR 101] Line 8:29 no viable alternative at input ''
[8,39]: [ERR 101] Line 8:39 no viable alternative at input ''
[9,29]: [ERR 101] Line 9:29 no viable alternative at input ''
[9,37]: [ERR 101] Line 9:37 no viable alternative at input '' 

...这只是在调试你的Drools决策表时需要考虑的一件小事。请注意,自2.2.0.CR1以来,Seam已添加决策表支持


返回顶部