3
votes

In xquery, I have a unknown length string str="/a/b/c" which I can split by tokenize(str, '/'), but what's the syntax to go through all the elements in tokenize result automatically based on string length?

for example /a/b/c will be a b c and for /a/b/c/d will be a b c d and so on.

1
is there a structure in xquery like in java which is like? for(int i=0;i<tokenize.length,i++) output(tokenize[i]) - user851380

1 Answers

5
votes

Use a plain old for (FLWOR) loop for this.

<tokens>{
 for $t in tokenize("a/b/c/d/e/f/g","/")
 return <token>{$t}</token>
}</tokens>