When working with certain layout types, such as XML, it is possible to have portions of the the input source repeat multiple times.
For example, the XML below has the tag multiple-occurrence
occur three times, each with unique nested values. This is referred to as a sublayout within Infogix Assure. In addition, the note
field occasionally displays multiple times within the sublayout.
This article will demonstrate how to capture when you have repeating fields. A related article will capture data from repeating sublayouts. The XML below will be used as the sample input source.
<sample-root>
<single-occurrence>
<external-value>
shared value across all IDs
</external-value>
<multiple-occurrence>
<id>100</id>
<note>first note</note>
<note>second note</note>
</multiple-occurrence>
<multiple-occurrence>
<id>200</id>
<note>sole note</note>
</multiple-occurrence>
<multiple-occurrence>
<id>300</id>
<note>note 1</note>
<note>note 2</note>
<note>note 3</note>
</multiple-occurrence>
</single-occurrence>
</sample-root>
Setting up the Infogix Assure layout
When using auto-generate to create the layout, the repeating sublayouts and field will be automatically picked up and defined. In some scenarios where repeats are less common or not defined in a schema, the automatic generation may not pick up on it.
To verify if your layout was creating correctly, open the sublayout or field that repeats and inspect the Occurs
field. This should be set to Many
to any item that repeats.
In the XML example at the beginning of this article, the multiple-occurrence
and note
items will have an Occurs
set to Many
:
Capturing data from repeating fields
This section assumes that you already have an understanding on how Infogix Assure controls are created and will focus on the specific steps within a Control Point's Capture tab to pull data from repeating fields.
The Note
field within the XML appears a variable amount of times within each sublayout occurrence. When this field is captured within the Capture tab, it will be stored as a List. There are several possibilities of what to capture from a list. This particular example will demonstrate how to capture the last occurrence of the Note
field.
The code highlighted below will dynamically determine the number of times the field is repeated and then select the last occurrence to store.
Several similar techniques can be used, such as replacing the @list_size
function with a literal of 0
to always capture the first occurrence, or a literal of 1
to always capture the second occurrence.
Comments
0 comments
Please sign in to leave a comment.