Use XPath expressions in mapping statements. XPath expressions identify the elements in the input document to be mapped and transformed in the output document. An XPath expression is also used to perform an arithmetic operation.
The following figure shows XPath expressions in the grid:
The XMap input document is a list of children and their hobbies. The input root is Children. Child is a multiple-occurring element within Children. Each child has a Name and multiple-occurring hobbies. Name consists of First, Initial, and Last elements.
The output is a list of the classes with the number of children in each class. The output root is Classes. Classes has an attribute that contains the total number of classes. Each input Hobby element maps to a output Class element. A Map statement concatenates the First, Initial, and Last elements into the Child output element. Another Map statement counts the number of chldren in each class. Another statement counts the number of classes.
The XMap contains the following expressions:
Grid row 2 expression <Class[@name = dp:input()]>
Adds a Class element or find a Class that matches Hobby. The dp:input() is required because the expression refers to an input element.