position

www.altova.com Print this Topic Previous Page Up One Level Next page

Home >  Functions > Function Library Reference > core | sequence functions >

position

Returns the position of a node inside its containing sequence.

fn-position

The position function allows you to determine the position of a specific node in a sequence, or use a specific position to filter out items based on that position.

 

The context item is defined by the item connected to the "node" parameter of the position function, Person, in the example below.

 

The simple mapping below adds a position number to each Person of each Department.

position-3

The position number is reset for each Department in the Office.

position-4

Using the position function to filter out specific nodes

 

Using the position function in conjunction with a filter allows you to map only those specific nodes that have a certain position in the source component.

 

The filter "node/row" parameter and the position "node" must be connected to the same item of the source component, to filter out a specific position of that sequence.

position-1a

What this mapping does is to output:

 

The second Person in each Department
of each Office in Altova.

position-2a

Finding the position of items in a filtered sequence:

 

As the filter component is not a sequence function, it cannot be used directly in conjunction with the position function to find the position of filtered items. To do this you have to use the "Variable" component.

 

The results of a Variable component are always sequences, i.e. a delimited list of values, which can also be used to create sequences.

 

The variable component is used to collect the filtered contacts where the last name starts with a letter higher than "M".
The contacts are then passed on (from the variable) to the target component
The position function then numbers these contacts sequentially

position-5


© 2019 Altova GmbH