I'd like to query something like
//model[ @id = (//item/@refid) ] to
obtain all "model" having a referenced
id in "list"
The main problem here is your lack of confidence and not actually running an XPath engine to evaluate the expressions you've come up with.
If you evaluate the XPath expression you proposed:
//model[ @id = (//item/@refid) ]
You'll see that it selects exactly the (two) model
elements, whose id
attributes are referenced by the refid
attributes of item
elements that are children of list
.
@Jörn-Horstmann in his answer already explained why you get these results.
A minor remark is to generally avoid using the //
abbreviation. It causes the whole document to be scanned and is very inefficient. In this case I would use the equivalent but probably faster to evaluate XPath expression:
/*/catalogue/model[@id = /*/list/item/@refid]