SIM:ActionDef
From RuleCore Support
Overview
Actions are defined using the AddActionDef system event and are found in the SIM as ActionDef items in the container located at /sim:SysInfo/sim:Items/sim:Item[@name="ActionDef"].
Contents
The ActionDef element contains an <Event> element, for example:
<Event> <EventRef><base:XPath>sim:EventDef[@eventType="Trigger" and @eventClass="user"]</base:XPath></EventRef> </Event>
The <Event> element is used to specify the oubound reaction event to be generated when the action is executed. The EventRef element is used to specify an XPath expression which must evaluate to a user event definition.
The body of the outbound reaction event is generated by the definition below the Body element. Currently the only allowed element is the <XsltBuilder> element.
The <XsltBuilder> element contains an XSLT stylesheet used to generate the body of the reaction event. The stylesheet is executed in the context of the rule instance to which the action is associated.
Example
To generate a Trigger event with an event body containing the entire rule instance state, we use a standard copy XSLT stylesheet and the following definition:
<ActionDef name="A1"> <Event> <EventDef> <base:XPath>sim:EventDef[@eventType="Trigger" and @eventClass="user"]</base:XPath> </EventDef> <Body> <XsltBuilder> <xsl:stylesheet version="1.0"> <xsl:template match="@*|node()"> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </xsl:template> </xsl:stylesheet> </XsltBuilder> </Body> </Event> </ActionDef>
Another example, generate a Trigger event and include the match value of the "vehicle" matcher of the default view:
<ActionDef name="A2"> <Event> <EventDef> <base:XPath>sim:EventDef[@eventType="Trigger" and @eventClass="user"]</base:XPath> </EventDef> <Body> <XsltBuilder> <Stylesheet><![CDATA[ <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:user="http://www.rulecore.com/2008/user" xmlns:base="http://www.rulecore.com/2008/base"> <xsl:template match="child::*"> <base:EventBody> <xsl:for-each select="user:Views/user:View[@default='true']/user:Properties"> <user:Vehicle><xsl:value-of select="descendant::user:MatchedProperty[@name='vehicle']/user:Value/child::text()"/></user:Vehicle> </xsl:for-each> </base:EventBody> </xsl:template> </xsl:stylesheet> ]]></Stylesheet> </XsltBuilder> </Body> </Event> </ActionDef>