BizTalk Server General - BRE repeating elements

This is Interesting: Free IT Magazines  
Home > Archive > BizTalk Server General > June 2005 > BRE repeating elements





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author BRE repeating elements
Ken

2005-06-28, 5:52 pm

I have a xml document (message) that has been populated via several
webservice calls, database lookups.

I now want the rule engine to evaluate each of the repeating elements
and update a fact in that specific repeating element.



The rule looks like this.

IF /person/relevantInfo/info.fase == "Fase 1" AND
/person/relevantInfo/info.type == "Policeregistration" THEN
/person/relevantInfo/info.dateUsed = occuranceDate1




<?xml version="1.0" encoding="utf-8"?>
<ns0:person xmlns:ns0="http://Somenamespace">
<personID>506038</personID>
<birthDate>1976-08-27Z</birthDate>
<hasGuardian>false</hasGuardian>
<relevantInfo>
<info>
<type>Emigration</type>
<code/>
<occuranceDate1>2002-03-26</occuranceDate1>
<occuranceDate2/>
<occuranceDate3/>
<occuranceDate4/>
<occuranceDate5/>
<occuranceDate6/>
<dateUsed>1900-01-01</dateUsed>
</info>
<info>
<type>Policeregistration</type>
<code>Fase 1</code>
<occuranceDate1>2001-05-23</occuranceDate1>
<occuranceDate2/>
<occuranceDate3/>
<occuranceDate4/>
<occuranceDate5/>
<occuranceDate6/>
<dateUsed>1900-01-01</dateUsed>
</info>
</relevantInfo>
<status>-1</status>
</ns0:person>


There can be a maximum of 6 dates for the info element but depending on
the type and the code I need to use different dates.
The date 1900-01-01 is just a default value that is ignored. Can this
be done in the rule engine.

Regards
Ken

Ken

2005-06-28, 5:52 pm

Sorry there was a small error in the above

The rule is like this

IF /person/relevantInfo/info.code =3D=3D "Fase 1" AND
/person/relevantInfo/info.type =3D=3D "Policeregistration" THEN
/person/relevantInfo/info.date=ADUsed =3D occuranceDate1

BA

2005-06-29, 2:47 am

Ken,

Yes, you can. You need to build rules for each condition and update your
dateUsed field, much like you have done below, but repeated for each
possibility. I guess your worry is that you wont be able to make a correct
determiniation, but you should be able to.

Just make sure you dont have the same conditions met multiple times.

BA


"Ken" <kenneth.thorman@gmail.com> wrote in message
news:1119985358.799386.15860@g49g2000cwa.googlegroups.com...
Sorry there was a small error in the above

The rule is like this

IF /person/relevantInfo/info.code == "Fase 1" AND
/person/relevantInfo/info.type == "Policeregistration" THEN
/person/relevantInfo/info.date_Used = occuranceDate1


Ken

2005-06-29, 2:47 am

Hi BA,

Thank you for taking the time

When using the HAT to monitor the policy execution details it looks as
though the rule engine evaluates the policy based on the whole xml
document. There is a match for the rule on several of the repeating
elements but the rule still does not fire? Is is possible to evaluate
the individual repeating elements isolated? Maybe I have got my XPath
expression wrong?

I am posting the details from HAT as well as the message in hope that
you might be able to tell me what is wrong
(Quite a few rules is needed in the final policy but for now I only
have one to make it simpler)

Instance message (on which the rules evaluate)

<?xml version="1.0" encoding="utf-8"?>
<ns0:person xmlns:ns0="http://Somenamespace">
<relevantInfo>
<info>
<type>Emigration</type>
<code/>
<occuranceDate1>2000-08-15</occuranceDate1>
<occuranceDate2/>
<occuranceDate3/>
<occuranceDate4/>
<occuranceDate5/>
<occuranceDate6/>
<dateUsed>1900-01-01</dateUsed>
</info>
<info>
<type>Emigration</type>
<code/>
<occuranceDate1>2001-11-29</occuranceDate1>
<occuranceDate2/>
<occuranceDate3/>
<occuranceDate4/>
<occuranceDate5/>
<occuranceDate6/>
<dateUsed>1900-01-01</dateUsed>
</info>
<info>
<type>Emigration</type>
<code/>
<occuranceDate1>2002-03-26</occuranceDate1>
<occuranceDate2/>
<occuranceDate3/>
<occuranceDate4/>
<occuranceDate5/>
<occuranceDate6/>
<dateUsed>1900-01-01</dateUsed>
</info>
<info>
<type>Policeregistration</type>
<code>Fase 1</code>
<occuranceDate1>2001-05-23</occuranceDate1>
<occuranceDate2/>
<occuranceDate3/>
<occuranceDate4/>
<occuranceDate5/>
<occuranceDate6/>
<dateUsed>1900-01-01</dateUsed>
</info>
<info>
<type>Policeregistration</type>
<code>Fase 1</code>
<occuranceDate1>2002-03-01</occuranceDate1>
<occuranceDate2/>
<occuranceDate3/>
<occuranceDate4/>
<occuranceDate5/>
<occuranceDate6/>
<dateUsed>1900-01-01</dateUsed>
</info>
<info>
<type>Policeregistration</type>
<code>Fase 1</code>
<occuranceDate1>2002-06-04</occuranceDate1>
<occuranceDate2/>
<occuranceDate3/>
<occuranceDate4/>
<occuranceDate5/>
<occuranceDate6/>
<dateUsed>1900-01-01</dateUsed>
</info>
<info>
<type>Policeregistration</type>
<code>Fase 1</code>
<occuranceDate1>2002-11-06</occuranceDate1>
<occuranceDate2/>
<occuranceDate3/>
<occuranceDate4/>
<occuranceDate5/>
<occuranceDate6/>
<dateUsed>1900-01-01</dateUsed>
</info>
</relevantInfo>
<code>-1</code>
<personID>506038</personID>
<birthDate>1976-08-27Z</birthDate>
<hasGuardian>false</hasGuardian>
</ns0:person>




What I would like after the rules have fired is this




<?xml version="1.0" encoding="utf-8"?>
<ns0:person xmlns:ns0="http://Somenamespace">
<relevantInfo>
<info>
<type>Emigration</type>
<code/>
<occuranceDate1>2000-08-15</occuranceDate1>
<occuranceDate2/>
<occuranceDate3/>
<occuranceDate4/>
<occuranceDate5/>
<occuranceDate6/>
<dateUsed>1900-01-01</dateUsed>
</info>
<info>
<type>Emigration</type>
<code/>
<occuranceDate1>2001-11-29</occuranceDate1>
<occuranceDate2/>
<occuranceDate3/>
<occuranceDate4/>
<occuranceDate5/>
<occuranceDate6/>
<dateUsed>1900-01-01</dateUsed>
</info>
<info>
<type>Emigration</type>
<code/>
<occuranceDate1>2002-03-26</occuranceDate1>
<occuranceDate2/>
<occuranceDate3/>
<occuranceDate4/>
<occuranceDate5/>
<occuranceDate6/>
<dateUsed>1900-01-01</dateUsed>
</info>
<info>
<type>Policeregistration</type>
<code>Fase 1</code>
<occuranceDate1>2001-05-23</occuranceDate1>
<occuranceDate2/>
<occuranceDate3/>
<occuranceDate4/>
<occuranceDate5/>
<occuranceDate6/>
<!-- Date has changed--><dateUsed>2001-05-23</dateUsed>
</info>
<info>
<type>Policeregistration</type>
<code>Fase 1</code>
<occuranceDate1>2002-03-01</occuranceDate1>
<occuranceDate2/>
<occuranceDate3/>
<occuranceDate4/>
<occuranceDate5/>
<occuranceDate6/>
<!-- Date has changed--><dateUsed>2002-03-01</dateUsed>
</info>
<info>
<type>Policeregistration</type>
<code>Fase 1</code>
<occuranceDate1>2002-06-04</occuranceDate1>
<occuranceDate2/>
<occuranceDate3/>
<occuranceDate4/>
<occuranceDate5/>
<occuranceDate6/>
<!-- Date has changed--><dateUsed>2002-06-04</dateUsed>
</info>
<info>
<type>Policeregistration</type>
<code>Fase 1</code>
<occuranceDate1>2002-11-06</occuranceDate1>
<occuranceDate2/>
<occuranceDate3/>
<occuranceDate4/>
<occuranceDate5/>
<occuranceDate6/>
<!-- Date has changed--><dateUsed>2002-11-06</dateUsed>
</info>
</relevantInfo>
<code>-1</code>
<personID>506038</personID>
<birthDate>1976-08-27Z</birthDate>
<hasGuardian>false</hasGuardian>
</ns0:person>




C# pseudo code:

foreach (XmlNode info in relevantInfo)
{
if ((info.type == "Policeregistration") && (info.code == "Fase 1"))
{
info.dateUsed = info.occuranceDate1;
}
}

Ken

2005-06-29, 7:52 am

HAT details

Policy Execution Details
Fact Activity

ID Activity Class Name
0 Asserted ---.personWithCodeInfo
1 Asserted ---.personWithCodeInfo:/person/relevantInfo/info
2 Asserted ---.personWithCodeInfo:/person/relevantInfo/info
3 Asserted ---.personWithCodeInfo:/person/relevantInfo/info
4 Asserted ---.personWithCodeInfo:/person/relevantInfo/info
5 Asserted ---.personWithCodeInfo:/person/relevantInfo/info
6 Asserted ---.personWithCodeInfo:/person/relevantInfo/info
7 Asserted ---.personWithCodeInfo:/person/relevantInfo/info
8 Retracted ---.personWithCodeInfo
9 Retracted ---.personWithCodeInfo:/person/relevantInfo/info
10 Retracted ---.personWithCodeInfo:/person/relevantInfo/info
11 Retracted ---.personWithCodeInfo:/person/relevantInfo/info
12 Retracted ---.personWithCodeInfo:/person/relevantInfo/info
13 Retracted ---.personWithCodeInfo:/person/relevantInfo/info
14 Retracted ---.personWithCodeInfo:/person/relevantInfo/info
15 Retracted ---.personWithCodeInfo:/person/relevantInfo/info

--------------------------------------------------------------------------------

Rules that Fired

--------------------------------------------------------------------------------

Rules that did not Fire

Rule ID Rule Name
0 Policeregistration - code 1

(
Aliased used in rule:
CODE1 (string) = "Code 1"
POLICEREGISTRATION (string) = "Policeregistration"
OCCURANCEDATE1 (xml element xs:date) = ...info.occuranceDate1
)


IF
(
xml:---.personWithCodeInfo./person/relevantInfo/info.code is equal
to CODE1 AND
xml:---.personWithCodeInfo./person/relevantInfo/info.type is equal
to POLICEREGISTRATION
)
THEN
xml:---.personWithCodeInfo./person/relevantInfo/info.dateUsed(OCCURANCEDATE1)


--------------------------------------------------------------------------------

Conditions that Evaluated
(not fra HAT but Business Rule Composer (Test)) due to no copy paste
from HAT


RULE ENGINE TRACE for RULESET: CodeDateChooser 29-06-2005 10:34:57

FACT ACTIVITY 29-06-2005 10:34:58
Rule Engine Instance Identifier: b5db6c64-ccd1-4621-8929-82baa8d0211b
Ruleset Name: CodeDateChooser
Operation: Assert
Object Type: TypedXmlDocument:---.personWithCodeInfo
Object Instance Identifier: 788

FACT ACTIVITY 29-06-2005 10:34:58
Rule Engine Instance Identifier: b5db6c64-ccd1-4621-8929-82baa8d0211b
Ruleset Name: CodeDateChooser
Operation: Assert
Object Type:
TypedXmlDocument:---.personWithCodeInfo:/person/relevantInfo/info
Object Instance Identifier: 787

CONDITION EVALUATION TEST (MATCH) 29-06-2005 10:34:58
Rule Engine Instance Identifier: b5db6c64-ccd1-4621-8929-82baa8d0211b
Ruleset Name: CodeDateChooser
Test Expression:
TypedXmlDocument:---.personWithCodeInfo:/person/relevantInfo/info.code
== Code 1
Left Operand Value:
Right Operand Value: Code 1
Test Result: False

FACT ACTIVITY 29-06-2005 10:34:58
Rule Engine Instance Identifier: b5db6c64-ccd1-4621-8929-82baa8d0211b
Ruleset Name: CodeDateChooser
Operation: Assert
Object Type:
TypedXmlDocument:---.personWithCodeInfo:/person/relevantInfo/info
Object Instance Identifier: 786

CONDITION EVALUATION TEST (MATCH) 29-06-2005 10:34:58
Rule Engine Instance Identifier: b5db6c64-ccd1-4621-8929-82baa8d0211b
Ruleset Name: CodeDateChooser
Test Expression:
TypedXmlDocument:---.personWithCodeInfo:/person/relevantInfo/info.code
== Code 1
Left Operand Value:
Right Operand Value: Code 1
Test Result: False

FACT ACTIVITY 29-06-2005 10:34:58
Rule Engine Instance Identifier: b5db6c64-ccd1-4621-8929-82baa8d0211b
Ruleset Name: CodeDateChooser
Operation: Assert
Object Type:
TypedXmlDocument:---.personWithCodeInfo:/person/relevantInfo/info
Object Instance Identifier: 785

CONDITION EVALUATION TEST (MATCH) 29-06-2005 10:34:58
Rule Engine Instance Identifier: b5db6c64-ccd1-4621-8929-82baa8d0211b
Ruleset Name: CodeDateChooser
Test Expression:
TypedXmlDocument:---.personWithCodeInfo:/person/relevantInfo/info.code
== Code 1
Left Operand Value:
Right Operand Value: Code 1
Test Result: False

FACT ACTIVITY 29-06-2005 10:34:58
Rule Engine Instance Identifier: b5db6c64-ccd1-4621-8929-82baa8d0211b
Ruleset Name: CodeDateChooser
Operation: Assert
Object Type:
TypedXmlDocument:---.personWithCodeInfo:/person/relevantInfo/info
Object Instance Identifier: 784

CONDITION EVALUATION TEST (MATCH) 29-06-2005 10:34:58
Rule Engine Instance Identifier: b5db6c64-ccd1-4621-8929-82baa8d0211b
Ruleset Name: CodeDateChooser
Test Expression:
TypedXmlDocument:---.personWithCodeInfo:/person/relevantInfo/info.code
== Code 1
Left Operand Value: Code 1
Right Operand Value: Code 1
Test Result: True

CONDITION EVALUATION TEST (MATCH) 29-06-2005 10:34:58
Rule Engine Instance Identifier: b5db6c64-ccd1-4621-8929-82baa8d0211b
Ruleset Name: CodeDateChooser
Test Expression:
TypedXmlDocument:---.personWithCodeInfo:/person/relevantInfo/info.type
== Policeregistration
Left Operand Value: Policeregistration
Right Operand Value: Policeregistration
Test Result: True

FACT ACTIVITY 29-06-2005 10:34:58
Rule Engine Instance Identifier: b5db6c64-ccd1-4621-8929-82baa8d0211b
Ruleset Name: CodeDateChooser
Operation: Assert
Object Type:
TypedXmlDocument:---.personWithCodeInfo:/person/relevantInfo/info
Object Instance Identifier: 783

CONDITION EVALUATION TEST (MATCH) 29-06-2005 10:34:58
Rule Engine Instance Identifier: b5db6c64-ccd1-4621-8929-82baa8d0211b
Ruleset Name: CodeDateChooser
Test Expression:
TypedXmlDocument:---.personWithCodeInfo:/person/relevantInfo/info.code
== Code 1
Left Operand Value: Code 1
Right Operand Value: Code 1
Test Result: True

CONDITION EVALUATION TEST (MATCH) 29-06-2005 10:34:58
Rule Engine Instance Identifier: b5db6c64-ccd1-4621-8929-82baa8d0211b
Ruleset Name: CodeDateChooser
Test Expression:
TypedXmlDocument:---.personWithCodeInfo:/person/relevantInfo/info.type
== Policeregistration
Left Operand Value: Policeregistration
Right Operand Value: Policeregistration
Test Result: True

FACT ACTIVITY 29-06-2005 10:34:58
Rule Engine Instance Identifier: b5db6c64-ccd1-4621-8929-82baa8d0211b
Ruleset Name: CodeDateChooser
Operation: Assert
Object Type:
TypedXmlDocument:---.personWithCodeInfo:/person/relevantInfo/info
Object Instance Identifier: 782

CONDITION EVALUATION TEST (MATCH) 29-06-2005 10:34:58
Rule Engine Instance Identifier: b5db6c64-ccd1-4621-8929-82baa8d0211b
Ruleset Name: CodeDateChooser
Test Expression:
TypedXmlDocument:---.personWithCodeInfo:/person/relevantInfo/info.code
== Code 1
Left Operand Value: Code 1
Right Operand Value: Code 1
Test Result: True

CONDITION EVALUATION TEST (MATCH) 29-06-2005 10:34:58
Rule Engine Instance Identifier: b5db6c64-ccd1-4621-8929-82baa8d0211b
Ruleset Name: CodeDateChooser
Test Expression:
TypedXmlDocument:---.personWithCodeInfo:/person/relevantInfo/info.type
== Policeregistration
Left Operand Value: Policeregistration
Right Operand Value: Policeregistration
Test Result: True

FACT ACTIVITY 29-06-2005 10:34:58
Rule Engine Instance Identifier: b5db6c64-ccd1-4621-8929-82baa8d0211b
Ruleset Name: CodeDateChooser
Operation: Assert
Object Type:
TypedXmlDocument:---.personWithCodeInfo:/person/relevantInfo/info
Object Instance Identifier: 781

CONDITION EVALUATION TEST (MATCH) 29-06-2005 10:34:58
Rule Engine Instance Identifier: b5db6c64-ccd1-4621-8929-82baa8d0211b
Ruleset Name: CodeDateChooser
Test Expression:
TypedXmlDocument:---.personWithCodeInfo:/person/relevantInfo/info.code
== Code 1
Left Operand Value: Code 1
Right Operand Value: Code 1
Test Result: True

CONDITION EVALUATION TEST (MATCH) 29-06-2005 10:34:58
Rule Engine Instance Identifier: b5db6c64-ccd1-4621-8929-82baa8d0211b
Ruleset Name: CodeDateChooser
Test Expression:
TypedXmlDocument:---.personWithCodeInfo:/person/relevantInfo/info.type
== Policeregistration
Left Operand Value: Policeregistration
Right Operand Value: Policeregistration
Test Result: True

FACT ACTIVITY 29-06-2005 10:34:58
Rule Engine Instance Identifier: b5db6c64-ccd1-4621-8929-82baa8d0211b
Ruleset Name: CodeDateChooser
Operation: Retract
Object Type: TypedXmlDocument:---.personWithCodeInfo
Object Instance Identifier: 788

FACT ACTIVITY 29-06-2005 10:34:58
Rule Engine Instance Identifier: b5db6c64-ccd1-4621-8929-82baa8d0211b
Ruleset Name: CodeDateChooser
Operation: Retract
Object Type:
TypedXmlDocument:---.personWithCodeInfo:/person/relevantInfo/info
Object Instance Identifier: 783

FACT ACTIVITY 29-06-2005 10:34:58
Rule Engine Instance Identifier: b5db6c64-ccd1-4621-8929-82baa8d0211b
Ruleset Name: CodeDateChooser
Operation: Retract
Object Type:
TypedXmlDocument:---.personWithCodeInfo:/person/relevantInfo/info
Object Instance Identifier: 782

FACT ACTIVITY 29-06-2005 10:34:58
Rule Engine Instance Identifier: b5db6c64-ccd1-4621-8929-82baa8d0211b
Ruleset Name: CodeDateChooser
Operation: Retract
Object Type:
TypedXmlDocument:---.personWithCodeInfo:/person/relevantInfo/info
Object Instance Identifier: 781

FACT ACTIVITY 29-06-2005 10:34:58
Rule Engine Instance Identifier: b5db6c64-ccd1-4621-8929-82baa8d0211b
Ruleset Name: CodeDateChooser
Operation: Retract
Object Type:
TypedXmlDocument:---.personWithCodeInfo:/person/relevantInfo/info
Object Instance Identifier: 787

FACT ACTIVITY 29-06-2005 10:34:58
Rule Engine Instance Identifier: b5db6c64-ccd1-4621-8929-82baa8d0211b
Ruleset Name: CodeDateChooser
Operation: Retract
Object Type:
TypedXmlDocument:---.personWithCodeInfo:/person/relevantInfo/info
Object Instance Identifier: 786

FACT ACTIVITY 29-06-2005 10:34:58
Rule Engine Instance Identifier: b5db6c64-ccd1-4621-8929-82baa8d0211b
Ruleset Name: CodeDateChooser
Operation: Retract
Object Type:
TypedXmlDocument:---.personWithCodeInfo:/person/relevantInfo/info
Object Instance Identifier: 785

FACT ACTIVITY 29-06-2005 10:34:58
Rule Engine Instance Identifier: b5db6c64-ccd1-4621-8929-82baa8d0211b
Ruleset Name: CodeDateChooser
Operation: Retract
Object Type:
TypedXmlDocument:---.personWithCodeInfo:/person/relevantInfo/info
Object Instance Identifier: 784

--------------------------------------------------------------------------------

Agenda Updates

Ken

2005-06-29, 7:52 am

Here is the schema for the message

(Note due to customer requirements the schema is not in english so I
have translated it to make more sense in this post. I migth have
misspelled a word or lost a cased letter somewhere so I am not sure
this will compile if you import it into BT.)

<?xml version="1.0" encoding="utf-16"?>
<xs:schema
xmlns:ns0="http://SomeNamespace.PropertySchema.PropertySchema"
xmlns="http://SomeNamespace.personWithCodeInfo"
xmlns:b="http://schemas.microsoft.com/BizTalk/2003"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://SomeNamespace.personWithCodeInfo">
<xs:annotation>
<xs:appinfo>
<b:imports xmlns:b="http://schemas.microsoft.com/BizTalk/2003">
<b:namespace prefix="ns0"
uri="http://SomeNamespace.PropertySchema.PropertySchema"
location=".\propertyschema.xsd"/>
</b:imports>
</xs:appinfo>
</xs:annotation>
<xs:element name="person">
<xs:annotation>
<xs:appinfo>
<b:properties>
<b:property name="ns0:personID" xpath="/*[local-name()='person'
and
namespace-uri()='http://SomeNamespace.personWithCodeInfo']/*[local-name()='personID'
and namespace-uri()='']"/>
<b:property name="ns0:birthDate" xpath="/*[local-name()='person'
and
namespace-uri()='http://SomeNamespace.personWithCodeInfo']/*[local-name()='birthDate'
and namespace-uri()='']"/>
<b:property name="ns0:hasGuardian" xpath="/*[local-name()='person'
and
namespace-uri()='http://SomeNamespace.personWithCodeInfo']/*[local-name()='hasGuardian'
and namespace-uri()='']"/>
<b:property name="ns0:code" xpath="/*[local-name()='person' and
namespace-uri()='http://SomeNamespace.personWithCodeInfo']/*[local-name()='code'
and namespace-uri()='']"/>
</b:properties>
</xs:appinfo>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:element name="relevantInfo">
<xs:complexType>
<xs:sequence>
<xs:element name="info" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence minOccurs="0" maxOccurs="unbounded">
<xs:element name="type" type="xs:string" minOccurs="0"/>
<xs:element name="code" type="xs:string" minOccurs="0"/>
<xs:element name="occuranceDate1" type="xs:date"
minOccurs="0"/>
<xs:element name="occuranceDate2" type="xs:date"
nillable="true" minOccurs="0"/>
<xs:element name="occuranceDate3" type="xs:date"
nillable="true" minOccurs="0"/>
<xs:element name="occuranceDate4" type="xs:date"
nillable="true" minOccurs="0"/>
<xs:element name="occuranceDate5" type="xs:date"
nillable="true" minOccurs="0"/>
<xs:element name="occuranceDate6" type="xs:date"
nillable="true" minOccurs="0"/>
<xs:element name="dateUsed" type="xs:date"
default="1900-01-01" nillable="true"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="code" type="xs:string" default="-1"/>
<xs:element name="personID" type="xs:int" default="1"/>
<xs:element name="birthDate" type="xs:date"/>
<xs:element name="hasGuardian" type="xs:boolean" default="false"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>


Thanks a lot
Ken

BA

2005-06-29, 7:52 am

Ken,

A very common problem in the BRE is that when you build a vocabulary the
"document type" does not get filled in with the fully qualified name. You
MUST have the fully qualified name or the schema will not be properly
matched when the rules fire. I have been caught out by this many times.

Are you using database connections? If so, how are you passing the
connection into the rules engine call.

Sort that out first to see if you have an easy problem.

BA


"Ken" <kenneth.thorman@gmail.com> wrote in message
news:1120032728.551778.57190@g44g2000cwa.googlegroups.com...
> Hi BA,
>
> Thank you for taking the time
>
> When using the HAT to monitor the policy execution details it looks as
> though the rule engine evaluates the policy based on the whole xml
> document. There is a match for the rule on several of the repeating
> elements but the rule still does not fire? Is is possible to evaluate
> the individual repeating elements isolated? Maybe I have got my XPath
> expression wrong?
>
> I am posting the details from HAT as well as the message in hope that
> you might be able to tell me what is wrong
> (Quite a few rules is needed in the final policy but for now I only
> have one to make it simpler)
>
> Instance message (on which the rules evaluate)
>
> <?xml version="1.0" encoding="utf-8"?>
> <ns0:person xmlns:ns0="http://Somenamespace">
> <relevantInfo>
> <info>
> <type>Emigration</type>
> <code/>
> <occuranceDate1>2000-08-15</occuranceDate1>
> <occuranceDate2/>
> <occuranceDate3/>
> <occuranceDate4/>
> <occuranceDate5/>
> <occuranceDate6/>
> <dateUsed>1900-01-01</dateUsed>
> </info>
> <info>
> <type>Emigration</type>
> <code/>
> <occuranceDate1>2001-11-29</occuranceDate1>
> <occuranceDate2/>
> <occuranceDate3/>
> <occuranceDate4/>
> <occuranceDate5/>
> <occuranceDate6/>
> <dateUsed>1900-01-01</dateUsed>
> </info>
> <info>
> <type>Emigration</type>
> <code/>
> <occuranceDate1>2002-03-26</occuranceDate1>
> <occuranceDate2/>
> <occuranceDate3/>
> <occuranceDate4/>
> <occuranceDate5/>
> <occuranceDate6/>
> <dateUsed>1900-01-01</dateUsed>
> </info>
> <info>
> <type>Policeregistration</type>
> <code>Fase 1</code>
> <occuranceDate1>2001-05-23</occuranceDate1>
> <occuranceDate2/>
> <occuranceDate3/>
> <occuranceDate4/>
> <occuranceDate5/>
> <occuranceDate6/>
> <dateUsed>1900-01-01</dateUsed>
> </info>
> <info>
> <type>Policeregistration</type>
> <code>Fase 1</code>
> <occuranceDate1>2002-03-01</occuranceDate1>
> <occuranceDate2/>
> <occuranceDate3/>
> <occuranceDate4/>
> <occuranceDate5/>
> <occuranceDate6/>
> <dateUsed>1900-01-01</dateUsed>
> </info>
> <info>
> <type>Policeregistration</type>
> <code>Fase 1</code>
> <occuranceDate1>2002-06-04</occuranceDate1>
> <occuranceDate2/>
> <occuranceDate3/>
> <occuranceDate4/>
> <occuranceDate5/>
> <occuranceDate6/>
> <dateUsed>1900-01-01</dateUsed>
> </info>
> <info>
> <type>Policeregistration</type>
> <code>Fase 1</code>
> <occuranceDate1>2002-11-06</occuranceDate1>
> <occuranceDate2/>
> <occuranceDate3/>
> <occuranceDate4/>
> <occuranceDate5/>
> <occuranceDate6/>
> <dateUsed>1900-01-01</dateUsed>
> </info>
> </relevantInfo>
> <code>-1</code>
> <personID>506038</personID>
> <birthDate>1976-08-27Z</birthDate>
> <hasGuardian>false</hasGuardian>
> </ns0:person>
>
>
>
>
> What I would like after the rules have fired is this
>
>
>
>
> <?xml version="1.0" encoding="utf-8"?>
> <ns0:person xmlns:ns0="http://Somenamespace">
> <relevantInfo>
> <info>
> <type>Emigration</type>
> <code/>
> <occuranceDate1>2000-08-15</occuranceDate1>
> <occuranceDate2/>
> <occuranceDate3/>
> <occuranceDate4/>
> <occuranceDate5/>
> <occuranceDate6/>
> <dateUsed>1900-01-01</dateUsed>
> </info>
> <info>
> <type>Emigration</type>
> <code/>
> <occuranceDate1>2001-11-29</occuranceDate1>
> <occuranceDate2/>
> <occuranceDate3/>
> <occuranceDate4/>
> <occuranceDate5/>
> <occuranceDate6/>
> <dateUsed>1900-01-01</dateUsed>
> </info>
> <info>
> <type>Emigration</type>
> <code/>
> <occuranceDate1>2002-03-26</occuranceDate1>
> <occuranceDate2/>
> <occuranceDate3/>
> <occuranceDate4/>
> <occuranceDate5/>
> <occuranceDate6/>
> <dateUsed>1900-01-01</dateUsed>
> </info>
> <info>
> <type>Policeregistration</type>
> <code>Fase 1</code>
> <occuranceDate1>2001-05-23</occuranceDate1>
> <occuranceDate2/>
> <occuranceDate3/>
> <occuranceDate4/>
> <occuranceDate5/>
> <occuranceDate6/>
> <!-- Date has changed--><dateUsed>2001-05-23</dateUsed>
> </info>
> <info>
> <type>Policeregistration</type>
> <code>Fase 1</code>
> <occuranceDate1>2002-03-01</occuranceDate1>
> <occuranceDate2/>
> <occuranceDate3/>
> <occuranceDate4/>
> <occuranceDate5/>
> <occuranceDate6/>
> <!-- Date has changed--><dateUsed>2002-03-01</dateUsed>
> </info>
> <info>
> <type>Policeregistration</type>
> <code>Fase 1</code>
> <occuranceDate1>2002-06-04</occuranceDate1>
> <occuranceDate2/>
> <occuranceDate3/>
> <occuranceDate4/>
> <occuranceDate5/>
> <occuranceDate6/>
> <!-- Date has changed--><dateUsed>2002-06-04</dateUsed>
> </info>
> <info>
> <type>Policeregistration</type>
> <code>Fase 1</code>
> <occuranceDate1>2002-11-06</occuranceDate1>
> <occuranceDate2/>
> <occuranceDate3/>
> <occuranceDate4/>
> <occuranceDate5/>
> <occuranceDate6/>
> <!-- Date has changed--><dateUsed>2002-11-06</dateUsed>
> </info>
> </relevantInfo>
> <code>-1</code>
> <personID>506038</personID>
> <birthDate>1976-08-27Z</birthDate>
> <hasGuardian>false</hasGuardian>
> </ns0:person>
>
>
>
>
> C# pseudo code:
>
> foreach (XmlNode info in relevantInfo)
> {
> if ((info.type == "Policeregistration") && (info.code == "Fase 1"))
> {
> info.dateUsed = info.occuranceDate1;
> }
> }
>



Ken

2005-06-29, 7:52 am

BA,

You were right. I used the fully qualified name for the schema to make
the rules but not for the vocabulary. This has been fixed and the rules
are firing as expected. However the dateUsed is not updated. I even
took the alias away and used the fully qualified xpath in the action to
make sure that I could update the date.

This is the rule now.
--- =3D fullyqualified path/name

IF
(
xml:---.personWithCodeInfo./pe=ADrson/relevantInfo/info.code is equal

to CODE1 AND
xml:---.personWithCodeInfo./pe=ADrson/relevantInfo/info.type is equal

to POLICEREGISTRATION
)
THEN
xml:---.personWithCodeInfo./pe=ADrson/relevantInfo/info.dateUse=ADd(xml:---=
..personWithCodeInfo./pe=ADrson/relevantInfo/info.occuranceDate1)


The rule fired 4 times as expected.

How come the dateUsed is not updated?

Ken

Ken

2005-06-29, 7:52 am

I am not using any database connections. The xml message
personWithCodeInfo has been populated in the orchestration prior to
calling this policy.

Flow:

1. SQL adapter selects from a table (personNeedsCodeUpdate) the result
is split into indvidual personWithCodeInfo
messages
2. Call a webservice that returns relevantinfo for the person and map
this info into the personWithCodeInfo message
3. (this is where we are now) evaluate which of the dates we need for
the different info elements and put into dateUsed.
4. find max(dateUsed) in message and put into variable maxDate (can
this be done in rule engine without a .NET component)?
5. find all elements that has dateUsed == maxDate
6. Evaluate rules which updates the personWithCodeInfo./person.code

string person.code;
foreach (XmlNode info in infoElementsWithMaxDate)
{
if (info.code == CODE2)
person.code = CODE2
if (info.code == CODE3 and person.code != CODE2)
person.code = CODE3
if (info.code == CODE1 and person.code != CODE2 or person.code !=
CODE3)
person.code = CODE1
}

Ken

2005-06-29, 7:52 am

Is it needed to do an "Update"/"Assert" in the action section of the
rule?

Is dateUsed = occuranceDate1 not enough?
Wonder if my XPath is specific enough since it potentially is not
pointing to which info[index].dateUsed to assign to?

Ken

BA

2005-06-29, 7:52 am

No, not in your context

Your rules will loop thru the tree and find the repeating nodes.



"Ken" <kenneth.thorman@gmail.com> wrote in message
news:1120043182.001794.212780@g49g2000cwa.googlegroups.com...
> Is it needed to do an "Update"/"Assert" in the action section of the
> rule?
>
> Is dateUsed = occuranceDate1 not enough?
> Wonder if my XPath is specific enough since it potentially is not
> pointing to which info[index].dateUsed to assign to?
>
> Ken
>



Ken

2005-06-29, 7:52 am

Hi BA,

Thanks alot again for taking the time.

Do you have any idear why dateUsed is not updated?

I simply does not seem to be able to update that field.
I have other rules in this orchestration which are updating fields in
the message without problem,
but this one just does not seem to work.

The only difference as far as I can tell is the repeating elements.


Regards
Ken

Ken

2005-06-29, 7:52 am

This is so embarrassing so I almost did not want to post it, however as
it might help others here it is.

The orchestration I am doing is rather large and I am using debugging
ports to see how the message looks underway in the orchestration
(Debug.Print with DebugViewNT could also be used). My send shape was
just prior to the call rule shape so that is why the message I was
looking at did not get updated.

Thanks for hanging in
Regards
Ken

BA

2005-06-29, 7:52 am

Ken,

No sweat... look at some of my old posts and you'll realize we all go thru
this.

BA



"Ken" <kenneth.thorman@gmail.com> wrote in message
news:1120048162.113396.289620@g43g2000cwa.googlegroups.com...
> This is so embarrassing so I almost did not want to post it, however as
> it might help others here it is.
>
> The orchestration I am doing is rather large and I am using debugging
> ports to see how the message looks underway in the orchestration
> (Debug.Print with DebugViewNT could also be used). My send shape was
> just prior to the call rule shape so that is why the message I was
> looking at did not get updated.
>
> Thanks for hanging in
> Regards
> Ken
>



Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com