at the start of the xml at startup or something create your units and make ONE of them a specific one you want:
createUnit('swordman', 0, 0)
swordmanUnit = lastCreatedUnit()
and somehow in the game you could:
createUnit('archer', 1, 1)
giveCommand(attack, swordmanUnit, 1)
something like that
though the player may be able to cancel the attack, in this case you would force attack using an ally unit not yours.