Table of Contents


  1. Preface
  2. Introduction to Data Transformation
  3. Data Processor Transformation
  4. Wizard Input and Output Formats
  5. Relational Input and Output
  6. Using the IntelliScript Editor
  7. XMap
  8. Libraries
  9. Schema Object
  10. Command Line Interface
  11. Scripts
  12. Parsers
  13. Script Ports
  14. Document Processors
  15. Formats
  16. Data Holders
  17. Anchors
  18. Transformers
  19. Actions
  20. Serializers
  21. Mappers
  22. Locators, Keys, and Indexing
  23. Streamers
  24. Validators, Notifications, and Failure Handling
  25. Validation Rules
  26. Custom Script Components

XPath Expressions Example

XPath Expressions Example

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 editor grid contains mapping statements with XPath expressions in the Input and Output fields. In the Input field, an XPath expression provides the context for the mapping statement. In an Output field, the XPath expression defines the output element.
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.
Grid row 3 expression <concat(../Name/First,' ',../Name/Initial,' ',../Name/Last)>
Concatenates the first name, middle initial, and last name and adds spaces between them.
Grid row 4 expression <dp:output()/@noOfChildren + 1>
For each Hobby that occurs, add 1 to the number of children for that class. The dp:output() function is required because the expression refers to an output element.
Grid row 5 expression <count(dp:output()/Class)>
Counts the Class elements. The dp:output() function is required because the expression refers to an output element.

Updated February 12, 2020