"Works" means that gives me what I need. The problem was that I need it as an option.And because I have to specify what kind of parameter is, they are elements:declare function p:funct($input as element(input)*)(: etc... I found this solution: maybe was only my Xpath ignorance :Pfor $d in doc("blabla.xml")//tag/tag2[tagsent=$actualparameter]Where the parameter is p:funct(<tagsent><tagsent2>A</tagsent2></tagsent>)I hope it is clear.But now I have a new problem. I have a variable $input like this:<input><pitch><step>C</step><octave>4</octave></pitch><pitch><step>D</step><octave>4</octave></pitch><pitch><step>E</step><octave>4</octave></pitch></input>I have to find these elements in sequence into an XML file. They may occur several times.let $n := count($input/pitch)for $d in doc("musicblabla.xml")//measure/note[pitch=$input/pitch[position()=1]]for $i in (1 to $n) return if ($i = 2) (: if it's the first time then $d[pitch=$input/pitch[position()=1]] (: print the match with the first note of input else $d[pitch=$input/pitch[position()=$i]] (: the second, third time etc... It seems like it does not increment $i, so the position also does not increment.Something like 11111, 22222, 33333What can I do?