Yes thats what I mean, thanks. But the solution didn't work for me.......

BindItem needs a XQItem not a QName as second parameter. So what do you mean with that ?

I changed the variabele in my xquery string to: "declare variable $element xs:XQItem() external;" (i also tried xs:QName).

Use the following binding:

XQItem qi = conn.createItemFromString("Number", null);
xqExpr.bindItem(new QName("element"), qi );

xquery adapt to :

"where $r1/*[node-name() = $element] = $r2/ID".

but error appear:
Error on line 1 column 129
  XPST0003: XQuery syntax error in #...atchingElement1 as xs:xqitem()#:
    Expected type name in SequenceType, found <function>(
Error on line 1 column 235