as a first step you should map the two arrays to 2 independent DocLists outside of the original document.
Then loop over the first list (schoolDetails).
Inside the loop there is a variable $iteration, which can be used for detecting the index.
With this information you can branch on the current entry of schoolDetails and then use pub.xml:queryXMLNode to question the second list (workDetails) to pick the matching entry with the value of $iteration.
See the IS Built-In-Services Reference for further informations on pub.xml:queryXMLNode.