Yes, you can pass an element name as a QName value and then write your query as
declare external variable $elementName as xs:QName;
//*[node-name() = $elementName]
You could also pass the name as a string, but then you have to think carefully about how you want to handle namespace prefixes. If you don't care about namespaces you could do
declare external variable $elementName as xs:string;
//*[local-name() = $elementName]


Michael Kay

From: Sweta Kedia []
Sent: 24 February 2010 10:16
Subject: [saxon] Variable xquery expression


I am using a xquery file from my java application which is implementing XQJ. I want to send the element names  used in xquery expression from my java application.
1) Is it possible to give element names as variables in xquery exrpession.

2) If it is possible can I bind the element  names as string from my application and use it in xquery expression or if there is another way for passing variable element names in same query.

Thanks in advance.