Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xquery to concatenate

Tags:

xquery

for the below data -

let $x := "Yahooooo !!!! Select one number - "
let $y := 
<A>
  <a>1</a>
  <a>2</a>
  <a>3</a>
  <a>4</a>
  <a>5</a>
  <a>6</a>
  <a>7</a>
</A>

I want to get the output as -

`Yahooooo !!!! Select one number - [1 or 2 or 3 or 4 or 5 or 6 or 7]`
like image 524
John Avatar asked Jan 14 '14 13:01

John


1 Answers

In XQuery 3.0, you can use || as a string concatenation operator:

return $x || "[" || fn:string-join($y/a, " or ") || "]"

In XQuery 1.0, you need to use fn:concat():

return fn:concat($x, fn:concat("[", fn:concat(fn:string-join($y/a, " or "), "]")))
like image 63
joemfb Avatar answered Oct 02 '22 07:10

joemfb