Pseudocode wise I want to do the following:

Attributes a,b, c, d, .. etc can have 0 or more value each.

Want to combine all unique values into a new attribute Z

My current-code:

<do-set-local-variable name="varValues" scope="policy">
<token-op-attr name="a"/>
<token-op-attr name="b"/>
<token-op-attr name="c"/>

<do-set-dest-attr-value name="Z">
<arg-value type="string">
<token-text xml:space="preserve">#dummy#</token-text>

<do-clone-xpath dest-expression="*[@attr-name='Z' and

<do-strip-xpath expression="self::*//value[ancestor::*/@attr-name='Z'
and . = '#dummy#']"/>

<do-strip-op-attr name="a"/>
<do-strip-op-attr name="b"/>
<do-strip-op-attr name="c"/>

With a very large XDS document (3000 adds), processing time and memory
is critical.

Anyone got a more efficient approach?