Hi Sony,
let $type := 'libapp' return doc('xyz')/entry[libx:{$type}][1]
This is invalid XQuery syntax; you could try the following:
let $type := 'libapp' return doc('xyz')/entry[name() = $type][1]
The following page gives you some more alternatives:
http://www.xqueryfunctions.com/xq/c0021.html
Christian ___________________________
On Tue, Apr 5, 2011 at 7:39 AM, Sony Vijay sony.vibh@gmail.com wrote:
Hi, I am using the sample xml document(xyz) shown below:
<entry xmlns:libx="http://libx.org/xml/libx2"> <libx:libapp> First libapp </libx:libapp> <libx:libapp> Second libapp </libx:libapp> </entry> I am using BaseX 6.5.2 and am trying to use a variable along with a namespace prefix in my sample xquery like so: declare variable $libx_ns as xs:string external; declare namespace libx=$libx_ns; let $type := 'libapp' return doc('xyz')/entry[libx:{$type}][1] When I pass the value "http://libx.org/xml/libx2" to the parameter libx_ns and run the above xquery I see the following exception: [XPST0003] Incomplete expression. However, the following xquery works: declare variable $libx_ns as xs:string external; declare namespace libx=$libx_ns; let $type := 'libapp' return doc('xyz')/entry[libx:libapp][1] The child nodes could be libx:libapp or libx:module etc. So, I will have to use a variable rather than hard wiring the actual child name. But, I am not sure how to use a variable along with a namespace prefix. Am I doing something wrong or is this a bug ? Thanks, Sony _______________________________________________ BaseX-Talk mailing list BaseX-Talk@mailman.uni-konstanz.de https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk