|
Home > Archive > BizTalk Server General > September 2005 > BizTalk 2004 :: Business Rules Engine :: missing elements crash engine
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 |
BizTalk 2004 :: Business Rules Engine :: missing elements crash engine
|
|
|
| Hello everyone,
I have experienced this limitation a number of times with the rules engine
and have found very little about it when searching google:
When you pass in an xml document with an element that is missing it causes
the rules engine to throw an error.
This is causing my development team quite a hassle.
We have considered a default blank space in the rules engine elements, but
this causes mapping problems when looping, creating blank elemented nodes
where we dont want them.
We tried the "EXISTS" predicate coupled with an "AND" condition but it
evaluates all the condition and doesnt seem to stop at the first failing
condition, the "EXISTS" condition.
The "HALT" function doesnt seem able to stop halt a specific rule, rather it
halts the entire policy execution.
Can someone please offer us a workaround for this problem?
Thanks in advance,
BA
| |
| esuyer@gmail.com 2005-09-23, 5:52 pm |
| Just venturing a guess here
Have you tried adding a condition like this
If ElementA is not null
AND ElementA is equal to "foo"
I believe this way, it will not get to this predicate (the failing
predicate) <ElementA is equal to "foo"> , unless this predicate
<ElementA is not null> passes
Can you give an xml sample and what your rule looks like
Also what's the error you get? And what happens when you use EXISTS?
| |
| Matt Milner 2005-09-23, 5:52 pm |
| I have seen this behavior, but it had to do with the fact that the exists
predicate was evaluating the xpath and if it found the item in any record it
was true. The problem was with the xpath selector and alias that we were
using for the exists.
I'd test just your exists to make sure you get the following results with
multiple records in your xml:
- if the element does not exist in any you should get false for all items.
If you have a bug, this should still work. I.E. your rules should not try to
evaluate the second part of the and as the exists will return false.
-if all of your elemements exists then you should get true for all items.
Again, if you have a bug, this should still work as the exists evaluates
once to true and then they all get set.
- if only some of the items have the element, then you should get those
correctly set. This is where your bug is catching you if it is evaluating
the exists only once.
By the way, it is easy to view the output of testing or running the policy
and check how many times the exists condition evaluates if you use scenario
1 or 2 above to test. Then you can see if this is truly your problem and
begin modifying the xpath. Also note that the default document selected
(the second argument in the exists predicate) may not be as specific as you
want so you might need to update it as well. The basic test will be the
xpath on the left run from the context of the element/record on the right.
Matt
"BA" <biztalk.architect@gmail.com> wrote in message
news:%23PHUXVDwFHA.708@TK2MSFTNGP10.phx.gbl...
> Hello everyone,
>
> I have experienced this limitation a number of times with the rules engine
> and have found very little about it when searching google:
>
> When you pass in an xml document with an element that is missing it causes
> the rules engine to throw an error.
>
> This is causing my development team quite a hassle.
>
> We have considered a default blank space in the rules engine elements, but
> this causes mapping problems when looping, creating blank elemented nodes
> where we dont want them.
>
> We tried the "EXISTS" predicate coupled with an "AND" condition but it
> evaluates all the condition and doesnt seem to stop at the first failing
> condition, the "EXISTS" condition.
>
> The "HALT" function doesnt seem able to stop halt a specific rule, rather
> it
> halts the entire policy execution.
>
> Can someone please offer us a workaround for this problem?
>
> Thanks in advance,
>
> BA
>
>
| |
|
| Hi Matt, thanks for the help.
Your suggestions do help but we are stuck getting the rule to return true
when the node we want exists.
I'm able now to see the rule evaluating more than once but we keep getting
false negatives, IE, when the node exists it still evaluates to false.
Here is a test sample of XML we created to test this, it looks like:
<root>
<person>
<lastName>Doe</lastName>
</person>
<person>
<firstName>John</firstName>
<lastName>Smith</lastName>
</person>
<person>
<lastName>Foo</lastName>
</person>
</root>
We want to loop the person nodes searching for firstName nodes.
I made a vocabulary entry for the firstName node and changed the Xpath from:
/*[local-name()='Root' and
namespace-uri()='http://RuleExistenceTest.Schema1']/*[local-name()='Person'
and namespace-uri()='']
to
/*[local-name()='Person' and namespace-uri()='']
And made the Xpath field just a '.' (no quotes)
The EXISTS rule looks like:
If <<vocab_firstName>> exists in <<Schema1:/root/Person>>
The right side was achieved by dragging the person node to the xml document
place holder, we also tried making the right side a vocab entry and modified
the path, again no results.
We've tried about 75 different variations on this theme with no results.
The rule is never able to match the node when the firstName exists.
I could use some direction, your post was very helpful getting us on the
right track as was this posting:
http://blogs.msdn.com/skaufman/arch.../30/344313.aspx
But we cant figure out the correct combination or correct setup for
executing the rule.
Thanks again,
BA
"Matt Milner" <matt.milner@m3technologypartners dot com> wrote in message
news:easdC0FwFHA.3000@TK2MSFTNGP12.phx.gbl...
> I have seen this behavior, but it had to do with the fact that the exists
> predicate was evaluating the xpath and if it found the item in any record
it
> was true. The problem was with the xpath selector and alias that we were
> using for the exists.
>
> I'd test just your exists to make sure you get the following results with
> multiple records in your xml:
> - if the element does not exist in any you should get false for all items.
> If you have a bug, this should still work. I.E. your rules should not try
to
> evaluate the second part of the and as the exists will return false.
> -if all of your elemements exists then you should get true for all items.
> Again, if you have a bug, this should still work as the exists evaluates
> once to true and then they all get set.
> - if only some of the items have the element, then you should get those
> correctly set. This is where your bug is catching you if it is evaluating
> the exists only once.
>
> By the way, it is easy to view the output of testing or running the policy
> and check how many times the exists condition evaluates if you use
scenario
> 1 or 2 above to test. Then you can see if this is truly your problem and
> begin modifying the xpath. Also note that the default document selected
> (the second argument in the exists predicate) may not be as specific as
you
> want so you might need to update it as well. The basic test will be the
> xpath on the left run from the context of the element/record on the right.
>
> Matt
>
>
> "BA" <biztalk.architect@gmail.com> wrote in message
> news:%23PHUXVDwFHA.708@TK2MSFTNGP10.phx.gbl...
engine[vbcol=seagreen]
causes[vbcol=seagreen]
but[vbcol=seagreen]
nodes[vbcol=seagreen]
rather[vbcol=seagreen]
>
>
| |
| esuyer@gmail.com 2005-09-26, 7:49 am |
| BA,
I plugged the exact XML sample you sent into XMLSpy and tested a few
different XPath expression variations. With the sample you sent
/*[local-name()='root']/*[local-name()='person']/*[local-name()='firstName']
returned John
The expression is case sensetive (and again matches the exact sample
you sent ... not sure if this is the actual xml or something you just
mocked up for this post). So that being said, I think your definition
of vocab_firstName needs to be
XPath Selector:
/*[local-name()='root']/*[local-name()='person']
XPath Field:
/*[local-name()='firstName']
or
XPath Selector:
/*[local-name()='root']
XPath Field:
/*[local-name()='person']/*[local-name()='firstName']
depending on how you intend to use it. But in both instances I believe
you should be able to use predicates like:
vocab_FirstName is equal to John
vocab_FirstName exists in Schema
vocab_FirstName is not null
w/o issue.
If you're not already doing so, I recommend you work through this
problem in the business rules composer using test policy. I find that
it's much easier to isolate the problem this way.
HTH
| |
|
| Hey HTH,
I tried your suggestion but the true result is returned without looping thru
the records.
That Xpath and selector and field combination is valid but in essence it is
saying "I have a true result in one or more of the 'person' nodes" which
will breakdown when setting values becuase it will attempt to traverse all
the person nodes, not individual nodes that have the firstName node.
I confirmed this and recieved the "Field 'x' does not exist in the xml
document" error.
I appreciate your help and hope you understand where I am still stuck. If
you do, any help would be greatly appreciated. We've burned up quite a few
hours dealing with this.
Cheers,
BA
PS, yes, the sample was just a record I mocked up, I'm using the test
feature in the composer as well
<esuyer@gmail.com> wrote in message
news:1127738181.053686.283770@g47g2000cwa.googlegroups.com...
> BA,
>
> I plugged the exact XML sample you sent into XMLSpy and tested a few
> different XPath expression variations. With the sample you sent
>
>
/*[local-name()='root']/*[local-name()='person']/*[local-name()='firstName']
>
> returned John
>
> The expression is case sensetive (and again matches the exact sample
> you sent ... not sure if this is the actual xml or something you just
> mocked up for this post). So that being said, I think your definition
> of vocab_firstName needs to be
>
> XPath Selector:
> /*[local-name()='root']/*[local-name()='person']
>
> XPath Field:
>
> /*[local-name()='firstName']
>
> or
>
> XPath Selector:
> /*[local-name()='root']
>
> XPath Field:
>
> /*[local-name()='person']/*[local-name()='firstName']
>
> depending on how you intend to use it. But in both instances I believe
> you should be able to use predicates like:
>
> vocab_FirstName is equal to John
> vocab_FirstName exists in Schema
> vocab_FirstName is not null
>
> w/o issue.
>
> If you're not already doing so, I recommend you work through this
> problem in the business rules composer using test policy. I find that
> it's much easier to isolate the problem this way.
>
> HTH
>
| |
| esuyer@gmail.com 2005-09-26, 5:59 pm |
| Try
Selector:
/*[local-name()=3D'root']/*[local-name()=3D'person'][firstName]
Field
@*[local-name()=3D'firstName'=AD]
This should only return person nodes w/ a firstName
| |
| Matt Milner 2005-09-26, 5:59 pm |
| I'd try something like this based on what you have said:
For the first name element, use this:
Selector: /*[local-name()='Root' and
namespace-uri()='http://RuleExistenceTest.Schema1']
Path: *local-name()='Person' and
namespace-uri()='']/*local-name()='firstname' and namespace-uri()='']
Then use the exists and drag the first name element onto the left side, then
drag the person element onto the right side.
I'm assuming here that the namespace and structure are accurate in your
example and that you are looking for items with the first name present.
If you want to send me the schema, or similar example schema, off line, I
can shoot you back a working policy with a rule that does the exists
correctly.
Matt
"BA" <biztalk.architect@gmail.com> wrote in message
news:%23OjlelowFHA.3692@TK2MSFTNGP11.phx.gbl...
> Hi Matt, thanks for the help.
>
> Your suggestions do help but we are stuck getting the rule to return true
> when the node we want exists.
>
> I'm able now to see the rule evaluating more than once but we keep getting
> false negatives, IE, when the node exists it still evaluates to false.
>
> Here is a test sample of XML we created to test this, it looks like:
>
> <root>
> <person>
> <lastName>Doe</lastName>
> </person>
> <person>
> <firstName>John</firstName>
> <lastName>Smith</lastName>
> </person>
> <person>
> <lastName>Foo</lastName>
> </person>
> </root>
>
> We want to loop the person nodes searching for firstName nodes.
>
> I made a vocabulary entry for the firstName node and changed the Xpath
> from:
>
> /*[local-name()='Root' and
> namespace-uri()='http://RuleExistenceTest.Schema1']/*[local-name()='Person'
> and namespace-uri()='']
>
> to
>
> /*[local-name()='Person' and namespace-uri()='']
>
> And made the Xpath field just a '.' (no quotes)
>
>
> The EXISTS rule looks like:
>
> If <<vocab_firstName>> exists in <<Schema1:/root/Person>>
>
> The right side was achieved by dragging the person node to the xml
> document
> place holder, we also tried making the right side a vocab entry and
> modified
> the path, again no results.
>
> We've tried about 75 different variations on this theme with no results.
> The rule is never able to match the node when the firstName exists.
>
> I could use some direction, your post was very helpful getting us on the
> right track as was this posting:
>
> http://blogs.msdn.com/skaufman/arch.../30/344313.aspx
>
> But we cant figure out the correct combination or correct setup for
> executing the rule.
>
> Thanks again,
>
> BA
>
>
> "Matt Milner" <matt.milner@m3technologypartners dot com> wrote in message
> news:easdC0FwFHA.3000@TK2MSFTNGP12.phx.gbl...
> it
> to
> scenario
> you
> engine
> causes
> but
> nodes
> rather
>
>
| |
|
| I tried your suggestion but it fails to select only the nodes which contain
a firstName node.
In a Xpath selector tool it does work but inside the rules engine it
generates another error message.
<esuyer@gmail.com> wrote in message
news:1127761489.026541.165280@f14g2000cwb.googlegroups.com...
Try
Selector:
/*[local-name()='root']/*[local-name()='person'][firstName]
Field
@*[local-name()='firstName'_]
This should only return person nodes w/ a firstName
| |
|
|
Hey Matt,
Correct, I am only looking for items with the first name present.
I tried your suggestion and some variations but I am again unable to
correctly select records which only have the first name present.
The real document I have to deal with has hundreds of fields, so this sample
was an attempt to get a simple model working.
I'll mail you what I have. Again, I appreciate the help.
BA
"Matt Milner" <matt.milner@m3technologypartners dot com> wrote in message
news:OM7B%23XtwFHA.2880@TK2MSFTNGP12.phx.gbl...
> I'd try something like this based on what you have said:
>
> For the first name element, use this:
> Selector: /*[local-name()='Root' and
> namespace-uri()='http://RuleExistenceTest.Schema1']
> Path: *local-name()='Person' and
> namespace-uri()='']/*local-name()='firstname' and namespace-uri()='']
>
> Then use the exists and drag the first name element onto the left side,
then
> drag the person element onto the right side.
>
> I'm assuming here that the namespace and structure are accurate in your
> example and that you are looking for items with the first name present.
>
> If you want to send me the schema, or similar example schema, off line, I
> can shoot you back a working policy with a rule that does the exists
> correctly.
>
> Matt
>
>
>
> "BA" <biztalk.architect@gmail.com> wrote in message
> news:%23OjlelowFHA.3692@TK2MSFTNGP11.phx.gbl...
true[vbcol=seagreen]
getting[vbcol=seagreen]
namespace-uri()='http://RuleExistenceTest.Schema1']/*[local-name()='Person'[vbcol=seagreen]
message[vbcol=seagreen]
exists[vbcol=seagreen]
record[vbcol=seagreen]
were[vbcol=seagreen]
with[vbcol=seagreen]
try[vbcol=seagreen]
items.[vbcol=seagreen]
evaluates[vbcol=seagreen]
and[vbcol=seagreen]
selected[vbcol=seagreen]
the[vbcol=seagreen]
elements,[vbcol=seagreen]
it[vbcol=seagreen]
>
>
| |
|
|
My thanks to Matt Milner for sending me a working policy and esuyer for
offering some suggestions.
The solution for situations like this is to drag the node for the 'Person'
to the right side of the EXISTS predicate and then to copy/paste the xpath
for ONLY the field in question (the one you want to loop thru that might or
might not exist)
When you finally get it working its rather intuitive but took me a while to
understand it.
So the rule looks like (ignore the differences in node names from other
posts):
*[local-name()='FirstName' and namespace-uri()=''] EXISTS IN
Schema1:/Root/Person
THEN
ACTIONS ...
If anyone is still confused mail me and I can get you the policy sample Matt
worked out for me.
Thanks for the help!
"BA" <biztalk.architect@gmail.com> wrote in message
news:ejThVnzwFHA.2072@TK2MSFTNGP14.phx.gbl...
> I tried your suggestion but it fails to select only the nodes which
contain
> a firstName node.
>
> In a Xpath selector tool it does work but inside the rules engine it
> generates another error message.
>
>
> <esuyer@gmail.com> wrote in message
> news:1127761489.026541.165280@f14g2000cwb.googlegroups.com...
> Try
>
> Selector:
> /*[local-name()='root']/*[local-name()='person'][firstName]
>
> Field
> @*[local-name()='firstName'_]
>
> This should only return person nodes w/ a firstName
>
>
| |
|
|
My thanks to Matt Milner for sending me a working policy.
The solution for situations like this is to drag the node for the 'Person'
to the right side of the EXISTS predicate and then to copy/paste the xpath
for ONLY the field in question (the one you want to loop thru that might or
might not exist)
When you finally get it working its rather intuitive but took me a while to
understand it.
So the rule looks like (ignore the differences in node names from other
posts):
*[local-name()='FirstName' and namespace-uri()=''] EXISTS IN
Schema1:/Root/Person
THEN
ACTIONS ...
If anyone is still confused mail me and I can get you the policy sample Matt
worked out for me.
Thanks for the help!
"BA" <biztalk.architect@gmail.com> wrote in message
news:eS2PmpzwFHA.3124@TK2MSFTNGP12.phx.gbl...
>
> Hey Matt,
>
> Correct, I am only looking for items with the first name present.
>
> I tried your suggestion and some variations but I am again unable to
> correctly select records which only have the first name present.
>
> The real document I have to deal with has hundreds of fields, so this
sample
> was an attempt to get a simple model working.
>
> I'll mail you what I have. Again, I appreciate the help.
>
> BA
>
> "Matt Milner" <matt.milner@m3technologypartners dot com> wrote in message
> news:OM7B%23XtwFHA.2880@TK2MSFTNGP12.phx.gbl...
> then
I[vbcol=seagreen]
> true
> getting
>
namespace-uri()='http://RuleExistenceTest.Schema1']/*[local-name()='Person'
results.[vbcol=seagreen]
the[vbcol=seagreen]
> message
> exists
> record
> were
> with
> try
> items.
> evaluates
those[vbcol=seagreen]
> and
> selected
as[vbcol=seagreen]
> the
> elements,
> it
>
>
|
|
|
|
|