Table of Contents

Search

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

Data Transformation User Guide

Data Transformation User Guide

Multiple-Occurrence Data Holders

Multiple-Occurrence Data Holders

In a schema, you can use the
maxOccurs
attribute to set the maximum number of times that sibling elements can occur in an XML document. Likewise, you can define a variable that can occur either once or multiple times. An element or variable that can occur only once is called a single-occurrence data holder. An element or variable that can occur more than once is called a multiple-occurrence data holder.
Single- and multiple-occurrence data holders behave differently when the Script stores data in them, for example, when you map
Content
anchors to a data holder.
  • In a single-occurrence data holder, each assignment overwrites the preceding assignment.
  • In a multiple-occurrence data holder, each assignment generates a new occurrence of the data holder.
To understand this, suppose that a schema defines an XML element called
<FirstName>
. If
maxOccurs = 1
, this is a single-occurrence data holder. If a Parser maps more than one
Content
anchor to the
<FirstName>
element, the output contains only the final mapping.
Consider what would happen if you parse a source document that is a list of first names:
Jack Jennie Larissa
We assume that each name is a
Content
anchor mapped to
FirstName
. Each name overwrites the value of
FirstName
. The output contains only the mapping:
<FirstName>Larissa</FirstName>
Now suppose that
maxOccurs = unbounded
. This means that
FirstName
is a multiple-occurrence data holder. If you map multiple
Content
anchors to the element, the Parser generates a list of names. The output is:
<FirstName>Jack</FirstName> <FirstName>Jennie</FirstName> <FirstName>Larissa</FirstName>
The same principle applies to variables. If you map multiple anchors to a multiple-occurrence variable, each anchor generates a new occurrence of the variable. You can use this feature, for example, to prepare input for the
AppendListItems
and
CombineValues
actions, which concatenate the occurrences.
The behavior described here assumes that the multiple-occurrence data holder has a simple data type. Under certain circumstances, if the type is complex, each anchor might not generate a new occurrence. To control this behavior, you can use a locator. For more information, see Overview of Locators, Keys, and Indexing.