Schedule tab  Using rule operators

Chapter 7: Using Unwired Accelerator Alerts

Rules tab

The Rules tab lets you specify rules that the application’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.

StepsSetting up agent rules

  1. Log in to Mobile Web Studio, select Automate | Agents from the left pane, then click New.

  2. When the Agent Builder appears, select the Rules tab.

  3. Select Execute Agent Based on a Rule and click Add. The Rule Editor window displays where you select the source of the rule’s criteria and create the actual rules.

  4. Base Rule On – select:

StepsBasing rules on an application’s content

  1. In the Rule Editor, select Application and click Find to select an application using the search dialog box. When you select the application and click Add, the application title appears in the Rule Editor’s Name drop-down list and the application’s content displays beneath Preview Source.

  2. Select Playback to display the application as it previews. Select XML to display the application 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:

    When the application 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.”

    NoteXPath 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 an application 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 on the W3 Schools Web site and on the ZVON Web site.

  3. At the bottom of the Rules panel, in the three unlabeled selection boxes after the term “Execute agent when,” select:

  4. Click the plus sign next to the rule to save the rule. Once you save the rule, the entry appears in the Rules panel.

  5. 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.

  6. When you finish, click OK to exit the Rule Editor and return to the Agent Builder. Click OK to save your entries.





Copyright © 2005. Sybase Inc. All rights reserved. Using rule operators

View this book as PDF