I think it is better to prevent duplicates in MSTP and MSONPC and put them into one template where input parameter will be non-duplicated VRPlanId as in XSL below:
You have edited your version of XML but in case of XML below:
The result is:
NOTE! In proposed XSL there is validation for empty values, if you will require include them just remove that validations.
In case when it is required to use each attribute value in separate task tag then you can create task blocks structure in separate template and call it in parameters block as below:
Then when you will check it with XML above the result will be as below:
Of course you can add blank values validation where it is required.
Hope it will help with your case.