distinct-values
Processes the sequence of values connected to the values input and returns only the distinct values, as a sequence. This is useful when you need to remove duplicate values from a sequence and copy only the unique items to the target component.
Languages
Built-in, C++, C#, Java, XQuery, XSLT 2.0, XSLT 3.0.
Parameters
Name | Description |
---|---|
values | This input must receive a connection from a mapping item that provides a sequence of zero or more values. For example, the connection may originate from a source XML item, a CSV field, a database record, and so on. |
Example
The following XML file contains information about employees of a demo company. Some employees have the same role; therefore, the "role" attribute role contains duplicate values. For example, both "Loby Matise" and "Susi Sanna" have the role "Support".
<?xml version="1.0" encoding="UTF-8"?> |
Let's suppose that you need to extract a list of all unique role names that occur in this XML file. This can be achieved with a mapping like the one below:
In the mapping above, the following happens:
•Each Property element from the source XML file is processed by a filter.
•The connection to the filter's bool input ensures that only Property elements where the Key attribute is equal to "role" are supplied to the target component. The string "role" is provided by a constant. Note that the filter's output still produces duplicates at this stage (since there are two "Support" properties that meet the filter's condition).
•The sequence produced by the filter is processed by the distinct-values function, which excludes any duplicate values.
As a result, the mapping output is as follows (excluding the XML and schema declarations):
<items> |