.. _functx_distinct-nodes: ===================== functx:distinct-nodes ===================== The distinct XML nodes in a sequence (by node identity) Description ~~~~~~~~~~~ The functx:distinct-nodes function returns the distinct nodes (based on node identity) in a sequence. It does this without resorting them in document order (it takes the first occurrence of each distinct node).It is different from the built-in fn:distinct-values function in that it returns nodes rather than atomic values, and it does not take into account the values (content) of the nodes, just their identity. Note: if you want them to be resorted in document order, or you don't care, you can simply use the expression "$nodes/." (without the quotes), which works because the slash operator removes duplicates and resorts. The "." in the expression returns the node itself. .. list-table:: :widths: 40 60 :header-rows: 1 * - **Parameters** - **Description** * - nodes:node() - the node sequence Examples ~~~~~~~~ .. list-table:: :widths: 25 25 50 :header-rows: 1 * - **XPath** - **Results** - **Explanation** * - functx:distinct-nodes(($in-xml/child, $in-xml/*)) - 1 2 3 3 - The two child elements that contain 3 have distinct identities, even if they contain the same content. * - functx:distinct-nodes(($in-xml/child[3], $in-xml/*)) - 3 1 2 3 - The 3 appears first because it is first in the input sequence. .. list-table:: :widths: 50 50 :header-rows: 1 * - **XPath** - **Results** * - functx:distinct-nodes(($in-xml/child, $in-xml/*)) - 1 2 3 3 * - functx:distinct-nodes(($in-xml/child[3], $in-xml/*)) - 3 1 2 3 Depends On ~~~~~~~~~~ * :ref:`functx_is-node-in-sequence`. See Also ~~~~~~~~ .. toctree:: :titlesonly: :glob: * :ref:`functx_distinct-deep`. * :ref:`distinct-values`.