Xquery to concatenate
Asked Answered
S

1

9

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]`
Sophistry answered 14/1, 2014 at 13:51 Comment(0)
V
15

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 "), "]")))
Voltcoulomb answered 14/1, 2014 at 14:4 Comment(1)
you can try this solution here: try.zorba.io/queries/xquery/6vZl50qj2vDtRAB%2BPBTSFMEN2Ds%3DHalfhour

© 2022 - 2024 — McMap. All rights reserved.