Home Page › Forums › BizTalk 2004 – BizTalk 2010 › BRE Forward chaining problem when using Schema as vocabulary
- This topic has 0 replies, 1 voice, and was last updated 9 years, 3 months ago by
community-content.
-
AuthorPosts
-
-
February 9, 2009 at 9:18 PM #21668
I have a list of exams and grades of various students in it. I want to calculate topper for each exam using BRE. The structure of my xml message looks like this:
<Exams>
<Exam>
<ExamID>1</ExamID>
<Topper>
<StudentName></StudentName>
<StudentGrade>0</StudentGrade>
</Topper>
<Grades>
<Grade>
<StudentName>A</StudentName>
<StudentGrade>5.2</StudentGrade>
</Grade>
<Grade>
<StudentName>B</StudentName>
<StudentGrade>6.5</StudentGrade>
</Grade>
</Grades>
</Exam>
<Exam>
<ExamID>2</ExamID>
<Topper>
<StudentName></StudentName>
<StudentGrade>0</StudentGrade>
</Topper>
<Grades>
<Grade>
<StudentName>C</StudentName>
<StudentGrade>5</StudentGrade>
</Grade>
<Grade>
<StudentName>D</StudentName>
<StudentGrade>9</StudentGrade>
</Grade>
</Grades>
</Exam>
</Exams>I am using following BRE policy to find the topper:
IF Exams:/Exams/Exam/Grades/Grade/StudentGrade is greater than Exams:/Exams/Exam/Topper/StudentGrade
THEN
Exams:/Exams/Exam/Topper/StudentGrade = Exams:/Exams/Exam/Grades/Grade/StudentGrade
Exams:/Exams/Exam/Topper/StudentName = Exams:/Exams/Exam/Grades/Grade/StudentName
update Exams:/Exams/Exam/Topperwhen i execute the above policy, The output which I get is wrong. Please see following xml:
<Exams>
<Exam>
<ExamID>1</ExamID>
<Topper>
<StudentName>D</StudentName>
<StudentGrade>9</StudentGrade>
</Topper>
<Grades>
<Grade>
<StudentName>A</StudentName>
<StudentGrade>5.2</StudentGrade>
</Grade>
<Grade>
<StudentName>B</StudentName>
<StudentGrade>6.5</StudentGrade>
</Grade>
</Grades>
</Exam>
<Exam>
<ExamID>2</ExamID>
<Topper>
<StudentName>D</StudentName>
<StudentGrade>9</StudentGrade>
</Topper>
<Grades>
<Grade>
<StudentName>C</StudentName>
<StudentGrade>5</StudentGrade>
</Grade>
<Grade>
<StudentName>D</StudentName>
<StudentGrade>9</StudentGrade>
</Grade>
</Grades>
</Exam>
</Exams>Ideally, BRE should calculate Topper for each exam separately but some how It is setting the Topper by comparing all the grades in xml, irrespective of their alliances with their parent node.
If I see the test policy output, It becomes clear that for every assert of grade 2 conditions getting loaded in memory for the same grade i.e. one for each exam. This might result in output going wrong. Please see below:
FACT ACTIVITY 2/10/2009 9:57:57 AM
Rule Engine Instance Identifier: 47154365-d742-4322-996c-412bdecf9106
Ruleset Name: ExamPolicy
Operation: Assert
Object Type: TypedXmlDocument:Exams:/Exams/Exam/Grades/Grade
Object Instance Identifier: 49044892CONDITION EVALUATION TEST (MATCH) 2/10/2009 9:57:57 AM
Rule Engine Instance Identifier: 47154365-d742-4322-996c-412bdecf9106
Ruleset Name: ExamPolicy
Test Expression: TypedXmlDocument:Exams:/Exams/Exam/Grades/Grade.StudentGrade > TypedXmlDocument:Exams:/Exams/Exam/Topper.StudentGrade
Left Operand Value: 5.2
Right Operand Value: 0
Test Result: TrueAGENDA UPDATE 2/10/2009 9:57:57 AM
Rule Engine Instance Identifier: 47154365-d742-4322-996c-412bdecf9106
Ruleset Name: ExamPolicy
Operation: Add
Rule Name: FindTopper
Conflict Resolution Criteria: 0CONDITION EVALUATION TEST (MATCH) 2/10/2009 9:57:57 AM
Rule Engine Instance Identifier: 47154365-d742-4322-996c-412bdecf9106
Ruleset Name: ExamPolicy
Test Expression: TypedXmlDocument:Exams:/Exams/Exam/Grades/Grade.StudentGrade > TypedXmlDocument:Exams:/Exams/Exam/Topper.StudentGrade
Left Operand Value: 5.2
Right Operand Value: 0
Test Result: Truecan any one let me know how can I get the correct output in above case.
Thanks and Regards,
Navneet
-
-
AuthorPosts
- The forum ‘BizTalk 2004 – BizTalk 2010’ is closed to new topics and replies.