Actual parameters into an XPath expression.

Hi, I’m working on a function that receives XML tags and insert the actual parameter into an XPath expressions to retrieve documents with those tags.
The problem is that if I use the parameter to move the context node ( / ) the query works, but I need to insert it like an option ( […] )

So:

for $d in doc(“blabla.xml”)//tag/tag2/$actualparameter <— this works
for $d in doc(“blabla.xml”)//tag/tag2[$actualparameter] <— this doesn’t work

I think that the actual parameter contains elements, so it’s the same if I write:

for $d in doc(“blabla.xml”)//tag/tag2/A
(works)

or

for $d in doc(“blabla.xml”)//tag/tag2[A]
(doesn’t work)

What can I do?
Thank you and sorry for my english :wink: