Did you try what I pasted on the rule on group6 that set's field3's value?
xdXDocument:GetDOM("test")/execution/subpara/subunit[count(current()/preceding-sibling::my:group6) + 1]/code
Code is not capitalized in your test data source when under subunit. That is why I said it is not capitalized. XPath is case sensitive.
You can set field3 to a value from an XML file.