tags:

views:

251

answers:

1

I have a function which contains a constructor:

declare function local:Construct ($id)
{
  <tag id="{$id}"/>
}

I use the function in return of "FLWOR":

for $val in ...
...
return local:Construct(data($val/id))

This works.

Now I want to concatenate two Constructs like this

for $val in ...
...
return local:Construct(data($val/id1)) + local:Construct(data($val/id2))

The plus sign is of course wrong. What should I use instead?

+2  A: 

I assume you want to return two nodes for each $val, in which case you want to use the , operator, like so:

for $val in ...
...
return (local:Construct(data($val/id1)), local:Construct(data($val/id2)))

The extra brackets are required, or you will be trying to concatenate local:Construct(data($val/id2)) onto the result of the FLWOR, which would result in an "undefined variable" error.

Oliver Hallam
Thank you. This is exactly what i need.
danatel