Adding rules to the ExportXML ruleset

To export line item grid data to an XML file, you must add the appropriate rules to the ExportXML ruleset.

Procedure

Adding rules to the ExportXML ruleset:

  1. In the Datacap Studio Rulesets pane, select the ExportXML ruleset and click Lock/Unlock ruleset for editing.
  2. Right-click the ExportXML ruleset and choose Add Rule. Rename the new rule Export Other XML Page Node.
  3. Right-click the ExportXML ruleset and choose Add Rule. Rename the new rule Export Other XML Line Item.
  4. Right-click the ExportXML ruleset and choose Add Rule. Rename the new rule Export Other XML Total Cost.
    The ExportXML ruleset includes the following rules:
    • Open XML File
    • Export Rental Agreement XML
    • Export Other XML Page Node
    • Export Other XML Line Item
    • Export Other XML Total Cost
    • Close XML File
  5. Expand the Open XML File rule and the Open XML function.
  6. Click the Actions library tab and expand the Export XML library.
  7. Select and add each of the following actions that are shown in the following table to the end of the Open XML function by clicking Add to function. Then, set the action parameters as shown in the second table.
    Action Parameter
    xml_NewNode Car_Rentals,BatchID_+@BatchID
    xml_NewNode Rental_Agreements,Car_Rentals
    xml_NewNode Flights,BatchID_+@BatchID
    xml_NewNode Hotels,BatchID_+@BatchID
    xml_NewNode Other_Charges,Hotels
  8. Expand the Export Other XML Page Node rule and select Function1.
  9. Select and add each of the actions that are shown in the following table to Function1 by clicking Add to function. Then, set the action parameters as shown in the table.
    Library Action Parameter
    ExportXML xml_NewNode @ID,Other_Charges
    rrunner

    rrSet

    (do not use rr_Set)

    varSource = @ID

    varTarget = @P.ID

    Important: xml_NewNode("@ID,Other_Charges") creates a new XML node by using the ID of the current page (for example, <TM000013>) beneath the <Other_Charges> node.

    rrset("@ID","@P.ID") stores the ID of the current page in a variable that is called ID within the runtime hierarchy (for example, <V n="ID">TM000013</V>.

  10. Expand the Export Other XML Line Item rule and select Function1.
  11. Select and add each of the actions that are shown in the following table to Function1 by clicking Add to function. Then, set the action parameters as shown in the table.
    Library Action Parameter
    ExportXML xml_NewNode Item,@P.ID
    ExportXML xml_SetAttributeValue Item,Category,@F\Category
    ExportXML xml_SetAttributeValue Item,Cost,@F\Total
    Important: xml_NewNode("Item,@P.ID") creates a new node <Item> that is a child of the node that you created in the Export Other XML Page Node rule. The @P.ID parameter identifies the parent node by using the ID variable of the page that you saved earlier by using rrset. You cannot reference the ID of a parent object by using a smart parameter.

    xml_SetAttributeValue("Item,Category,@F\Category") creates a Category attribute on the current <Item> node and sets the value to the value of the current line item's Category field (for example, <Item Category=Internet/>).

    The xml_SetAttributeValue("Item,Cost,@F\Total") parameter is the same except that the attribute is Cost and the value is the current line item's Total field (for example, <Item Cost="9.90"/>.

  12. Expand the Export Other XML Total rule and select Function1.
  13. Select and add each of the actions in the following table to Function1 by clicking Add to function. Then, set the action parameters as shown in the table.
    Library Action Parameter
    ExportXML xml_NewNode Total_Cost,@P.ID
    ExportXML xml_SetNodeValue Total_Cost, @P\Other_Charges_Total
    Important: xml_NewNode("Total_Cost,@P.ID") creates a new XML node that is called <Total__Cost> beneath the page node that you created in the Export Other XML Page Node rule. The xml_SetNodeValue action sets the value of this node to the value of the current page's Other_Charges_Total field (for example, <Total_Cost>$238.75</Total_Cost>).
  14. In the Rulesets pane, click Save. Then, click Lock/Unlock ruleset and choose Publish ruleset.