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]
 

Regards,

Michael Kay
http://www.saxonica.com/
http://twitter.com/michaelhkay



From: Sweta Kedia [mailto:swetakedia@gmail.com]
Sent: 24 February 2010 10:16
To: saxon-help@lists.sourceforge.net
Subject: [saxon] Variable xquery expression

Hi,

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.

Sweta