position()
gives the context's position (where it's called from). ../../data[@id='second']/coord[position()]
actually means "every coord
under the second data
which is in it's own position" (which is all of them but XPath 1.0 string conversion only takes the first one).
To refer to the coord
you're looping on, you can use the XSLT function current(). This doesn't work with position()
for some good reason that I can't think of right now, but you can count() the preceding-sibling
nodes instead:
xml sel -T -t -m "/alldata/data[@id='first']/coord" -v "concat(x,';',y,';',../../data[@id='second']/coord[count(current()/preceding-sibling::*)+1]/y)" -n mydata.xml