I need to take the eDir @qualified-src-dn value, and transform it into
an LDAP DN.

Problem is, eDir's comes in backslash format, in the same order as usual
backslash format (Rootmost first). LDAP of course is the other way around:

dc=com\dc=acme\ou=cont\cn=user

Ok, I can replace \ with , but that leaves me backwards still.

I tried ParseDN and it leaves me in reverse order with commas still.
How frustrating! I vote for a smarter ParseDN!!!

I wrote this code quick:
<do-set-local-variable name="FQDN" scope="policy">
<arg-node-set>
<token-split delimiter="\\">
<token-xpath expression="@qualified-src-dn"/>
</token-split>
</arg-node-set>
</do-set-local-variable>
<do-set-local-variable name="J" scope="policy">
<arg-string>
<token-xpath expression="count($FQDN)"/>
</arg-string>
</do-set-local-variable>
<do-set-local-variable name="I" scope="policy">
<arg-string>
<token-text xml:space="preserve">2</token-text>
</arg-string>
</do-set-local-variable>
<do-set-local-variable name="OUTPUT" scope="policy">
<arg-string>
<token-xpath expression="$FQDN[1]"/>
</arg-string>
</do-set-local-variable>
<do-while>
<arg-conditions>
<and>
<if-xpath op="not-true">number($I)=number($J)</if-xpath>
</and>
</arg-conditions>
<arg-actions>
<do-set-local-variable name="OUTPUT" scope="policy">
<arg-string>
<token-xpath expression="$FQDN[$I]"/>
<token-text xml:space="preserve">,</token-text>
<token-local-variable name="OUTPUT"/>
</arg-string>
</do-set-local-variable>
<do-set-local-variable name="I" scope="policy">
<arg-string>
<token-xpath expression="number($I) + 1"/>
</arg-string>
</do-set-local-variable>
</arg-actions>
</do-while>


Problem is that $FQDN[$I] is returning the first node every time, which
means I am casting a nodeset onto a string I guess.

So I am not getting the iTH element of the nodeset.

I was pretty sure that ought to have worked. I know I could do
$FQDN/last() but that is not helpful either.

As usual, the act of writing this question found me the answer! So I
will post it anyway...

Looks like I needed to use XPATH of $FQDN[position()=1] and
$FQDN[position()=$I] in my two uses of it.

Is there a shorter or more efficient notation to use?

Or is there a better way to do what I need?