The Rules tab lets you specify rules that the portlet’s content must meet before the action associated with the agent can be executed. For example, you may want an agent to notify certain people of a stock price only when that price reaches a specified amount.
Setting up agent rules
Log in to Web Studio, select Automate | Agents from the left pane, then click New.
When the Agent Builder appears, select the Rules tab.
Select Execute Agent Based on a Rule and click Edit. The Rule Editor window displays where you select the source of the rule’s criteria and create the actual rules.
Base Rule On – select:
Portlet – to base the rule on a selected portlet’s content. See the next procedure, “Basing rules on a portlet’s content.”
Criteria – to base the rule on criteria that you specify. See the procedure, “Basing rules on criteria.”
Basing rules on a portlet’s content
In the Rule Editor, select Portlet and click Find to select a portlet using the search dialog box. When you select the portlet and click Add, the portlet title appears in the Rule Editor’s Name drop-down list and the portlet’s content displays beneath Preview Source.
Select Playback to display the portlet as it previews. Select XML to display the portlet as XML.
The Rules section allows you to group rules together based on the Boolean operators “AND” or “OR.” See “Using rule operators” for a description of each operator.
Additional options let you select how to construct the rules based on:
Label – uses column labels in the data. When table fields reorder, the rule still picks up the correct field.
Position – an index on positions in the data.
XPath – if you choose to view the content as XML, this option allows all matches to be done via XPath expressions.
XPath is a set of syntax rules for defining parts of
an XML document.
When the portlet displays as XML, you see this code:
<?xml version="1.0" encoding="UTF-8" ?> - <ContentDoc> - <Element name="bonds"> - <Record> <Field op_label="Maturity" op_position="1">Maturity</Field> <Field op_label="Yield" op_position="2">Yield</Field> <Field op_label="Yester- day" op_position="3">Yesterday</Field> <Field op_label="Last Week" op_position="4">Last<BR>Week</Field> <Field op_label="Last Month" op_position="5">Last<BR>Month </Field> </Record> - <Record> <Field op_label="Maturity" op_position="1">3 Month</Field> <Field op_label="Yield" op_position="2">0.99</Field> <Field op_label="Yester- day" op_position="3">1.00</Field> <Field op_label="Last Week" op_position="4">0.97</Field> <Field op_label="Last Month" op_position="5">1.04</Field> </Record> ...More XML records follow...
“Label” matches the XML op_label attribute and “Position” matches the XML op_position attribute.
XPath uses path expressions to locate nodes within XML documents. XML documents can be represented as a tree view of nodes.Any XPath expression that uses partial paths starts at each “record” node and is applied. Unstructured data is in one record, so the pop-up selections for Label and Position contain only “content.”
XPath and the comparable options are valuable rule options.
You can use the comparable options of “found” and “not
found” to check if a specific node is found in an XML document
regardless of the text content. This is useful to see if a portlet
is broken, or has been changed in a way that requires attention.
To learn more about XPath, see the OASIS specification .
Additional examples to help you understand how to use XPath are available and .
At the bottom of the Rules panel, in the three unlabeled selection boxes after the term “Execute agent when,” select:
1st box – Maturity
2nd box – equals (text)
3rd box – 3 months
Click the plus sign next to the rule to save the rule. Once you save the rule, the entry appears in the Rules panel.
To edit a rule, click the check mark. To delete a rule, click the X.
When you edit an entry, the check mark changes to plus sign. Click the plus sign to save your changes.
When you finish, click OK to exit the Rule Editor and return to the Agent Builder. Click OK to save your entries.
Copyright © 2004. Sybase Inc. All rights reserved. |
![]() |