All business rules use XPath navigation to help the user traverse the data model in an intuitive way.
The XPath standard is a easy-to-use language for finding information in an XML document and is helpful in carrying out complex tasks. Bizagi incorporated this concept into its language, enabling users to easily navigate and use the data model to accomplish different tasks.
XPath as a navigation tool enables users to navigate the data model accessing attributes and relationships.
The 'location path' of the desired attribute in the data model is always written between angle brackets:
< XPath route >
We can access any entity, and its attributes, as long as we follow the hierarchy that is laid out in the Data Model. XPath expressions will always begin with the Process Entity as the first attribute and from there navigate the rest of the data model. Data model navigation is defined by the relationships which are represented by arrows in the data model.
The data model diagram below will be used as a guide to show how XPath works. A Purchase Request Process has a Process entity called Purchase Request. Consequently, the context is the Purchase Request entity through which the rest of the data model can be reached and is the starting point of the XPath navigation.
Using XPath you can obtain the value stored in an attribute or you can set a value to one.
To obtain the delivery address of the Purchase Request, you would use the expression: <PurchaseRequest.DeliveryAdress>
To get the delivery date of the Purchase Request, you would use the expression: <PurchaseRequest.RequiredDeliveryDate>
To identify the city for this delivery and retrieve its name , you would use the expression: <PurchaseRequest.City.Name>
It is also possible to navigate collections by means of using the relationship's name. The relationship's name is shown in the arrow connecting the two entities in the diagram and is also demarcated by an asterisk (the non asterisked paths between entities are the related attribute relationships).
To obtain the collection of all Products Requested for the Purchase Request, you would use the expression: <PurchaseRequest.ProductsRequested>
To retrieve every Product Name of all Products Requested for the Purchase Request, you would the expression: <PurchaseRequest.ProductsRequested.ProductName.Product>
Assign and obtain values with XPath
The easiest way to assign a value to an element is using the "=" operator.
<PurchaseRequest.DeliveryAdress> = "101 Bizagi Road"
This expression assigns the address to the delivery address attribute.
<PurchaseRequest.RequiresApprovalForProduct> = true
This expression sets the Boolean attribute's value to true.
var date =<PurchaseRequest.RequiredDeliveryDate>
This expression stores the required delivery date in a variable.
Values can also be assigned to collections.
<PurchaseRequest.ProductsRequested.UnitPrice> = 1000
This expression sets the unit price of ALL requested products to "1000".
var quantity = <PurchaseRequest.ProductsRequested.Quantity>
This expression will return a one-column collection containing the number of quotations requested (quantity) of each product related to every purchase. The collection variable will store the quantity for every product requested related to each purchase.
Take great care that the attribute data types are compatible with those of the values you assign.
For example, you cannot assign a string (like "101 Bizagi Road") to an integer attribute, or similarly, assign a number (like 1000) to a Boolean attribute, which expects a true or a false value.