| Dominic Messenger 2004-07-09, 5:48 pm |
| We are using the Biztalk RuleEngine in a standalone environment. The
idea is that users can create their own rulesets (using a custom tool)
and custom calculation libraries that are loaded from file-based
rulestores. We are not using the Rule Composer for any policy
development. The calculations are written in JScript/Ecmascript so
they can be executed in multiple environments.
The problem we are having is passing an Xml Element (with child nodes)
to our calculation library. Coercing simple elements or attributes to
int, double, string etc works (e.g.
CalculationLib.NetSalary(Employee/Salary) > 30000), but trying to pass
an element with child nodes (e.g.
CalculationLib.SomethingInteresting(Employee) = "x") passes the
InnerText of the element to our ClassBinding and NOT the XmlNode as we
would expect.
I have set the Type when creating the XMLDocumentFieldBinding to
typeof(Microsoft.RuleEngine.TypedXmlDocument) in the hope this would
work, but it doesn't :
// snippet
XMLDocumentBinding xdb = new XMLDocumentBinding(schemaName, root);
System.Type type = Type.GetType(termDataType);
if(type == typeof(object)) // the XPath is to an element with children
{
type = typeof(Microsoft.RuleEngine.TypedXmlDocument);
}
XMLDocumentFieldBinding xfb = new XMLDocumentFieldBinding(type , new
XPathPair(termAlias, rootXPath),xdb);
// end snippet
The only thing I can think of is creating a proxy fact which takes the
XPath we would have put in the XMLDocumentFieldBinding and this
extracts the XmlNode from the TypedXmlDocument.Document. Is there an
easier way to get this to work ?
I would appreciate anything using the RuleEngine API, or XML snippets
from an exported policy as we are not using the Rule Composer at all.
|