Ankur Agarwal
Ankur Agarwal

Reputation: 24748

Construct XQuery element attributes

I have this XQuery element that is giving me an error:

let $mx := 7
for $b in doc("abc.xml")//test
   where $b/@attr = $mx
return 
<mytag myattr="$mx">

{$b/data(@name)}

</mytag>    

I want to return the value of $mx as the myattr attribute. Any pointers?

Upvotes: 2

Views: 247

Answers (1)

Dimitre Novatchev
Dimitre Novatchev

Reputation: 243459

Use AVTs (Attribute Value Templates) for this:

<mytag myattr="{$mx}">

Upvotes: 3

Related Questions