As your file does have an AP integer index # beginning with 1 for each facility, and you can count the number of APs per facility correctly, you could look up each one matching the repeat position with the index #.
eg:
- put a calculate field in the repeat like ${repeat_index} with a calculation
position(..) - have another calculate that gets the AP text like
instance('action_points')/root/item[facility_name = ${facility}][${repeat_index}=point_index]/label - and another that replaces
labelwithaction_point_id
But if you make an error in the point index (skip or duplicate a value) it will break, so you could be fancy and ignore the index value completely and simply pull the values in the order they exist in the file where list order value = repeat position value, eg:
- have a calculate that gets the AP text like
instance('action_points')/root/item[facility_name = ${facility}][position()=position(current()/..)]/label
Some of what I was trying recently might also help you, as I was dynamically building and populating repeats:
BTW: your facilities choice list has spaces in it, it would be better to remove these as spaces are used to separate select multiples, nodesets etc.