Defining Rule Sets for XML Virtual Documents
This chapter discusses how to create rule sets for XML virtual documents, for use in business processes.
To configure a business process to use a rule set, specify its Business Rule Name setting; see “Adding a Business Process to Handle XML Virtual Documents,” earlier in this book.
Creating a Rule Set
To create a rule set for XML virtual documents:
Optionally load the applicable XML schema or schemas into InterSystems IRIS®.
See “Loading XML Schemas into InterSystems IRIS” earlier in this book.
Use the Rule Set editor in the Management Portal or in Studio, as described in Developing Business Rules.
For the rule set basic definition, use Virtual Document Message Routing Rule for Type.
This choice sets Context Class to EnsLib.MsgRouter.VDocRoutingEngineOpens in a new tab. It also sets Rule Assist Class to EnsLib.MsgRouter.VDocRuleAssistOpens in a new tab.
For any rule constraint in the rule set, use the following values:
For Message Class, use EnsLib.EDI.XML.Document, the class with which InterSystems IRIS represents XML virtual documents.
For Schema Category, optionally select an XML schema that you have previously loaded into InterSystems IRIS.
Leave this value blank if you do not have or do not want to use the schema.
For Document Name, optionally select a document type defined in that schema.
Leave this value blank if you have not specified Schema Category.
Create rules as usual, using the XML property paths described earlier in this book. There are two basic scenarios:
If you have loaded the schema and have specified the target document type, the Expression Editor provides assistance when you start typing Document.
Notice that these property paths are schema-dependent paths, although you could edit them to be DOM-style paths instead, if those are needed for some reason.
If you have not loaded the schema and specified the document type, you must type the path manually. You can use either schema-dependent paths or DOM-style paths.
After you save and compile the rule set, it is available for use in a business process.
The following shows the class definition for a simple rule set. This rule set has one rule that uses a DOM-style path to check the <MRN> element of the <Patient> document. Depending on the returned value, the rule routes the message to either FileOut1 or FileOut2. Notice that in this case, the rule constraint does not refer to the XML schema or type.
Class Demo09.MyRules Extends Ens.Rule.Definition
Parameter RuleAssistClass = "EnsLib.MsgRouter.VDocRuleAssist";
XData RuleDefinition [ XMLNamespace = "http://www.intersystems.com/rule" ]
<ruleDefinition alias="" context="EnsLib.MsgRouter.VDocRoutingEngine">
<ruleSet name="" effectiveBegin="" effectiveEnd="">
<rule name="CheckMRN" disabled="false">
<constraint name="msgClass" value="EnsLib.EDI.XML.Document"></constraint>
<send transform="" target="FileOut1"></send>
<send transform="" target="FileOut2"></send>