Xquery concat / string-join / replace
755655Mar 9 2010 — edited Mar 9 2010Hi, I am a newbie on Xquery.
And I need some help on a problem I been having.
My in data is three digit numbers (ex. "123" "321" "213" etc). And I need to separate this with a comma ",". The problem is how do I do this if the input is only one item?, and second how do I not
put a "," on the last item?
I have tried a for-loop where a concat my string with with "," but the result is "123, 321, 213,". I do not want the last comma. And the spaces is not real whitespaces. I don't know where this comes from, the can not be removed or be used to
replace them with a comma (which would be the simplest way to solve my problem) but doesn't work.
for $Something in $Something/ns0:Something
return
fn:concat(data($Something)," ",",").
This returns "123, 321, 213,".