To have XPath reference the main data source when it is already in the context of another, you can use xdXDocument:get-DOM():
xdXDocument:GetDOM("ClientInformationDC")/dfs:myFields/dfs:dataFields/d:Companies[@ID
= xdXDocument:get-DOM()/my:myFields/my:ClientInformation/my:CompanyID]/@Name
InfoPath will usually do this for you if you use the Select Field... button, though I think sometimes it won't be smart enough to figure out you're going back and forth between data sources.