You want to run string-join() on the result of the entire FLWOR
expression, not in the return clause where it is run once per iteration
of the FLWOR:
let $input := "abc/def/ghi"
return string-join(
for $values in fn:tokenize($input,"\/")
return fn:doc("externalFile.xml")//entry[@code = $values]/
@value/string()
,"/")
John
On 21/01/13 10:31, sini narayanan wrote:
>
> Hi All,
>
> I have a string which has multiple values in it.
>
> Example:
> let $input := "abc/def/ghi"
>
> External xml file have the following values:
> <root>
> <entry code="abc" value="123"/>
> <entry code="def" value="456"/>
> <entry code="ghi" value="789"/>
> </root>
>
>
> My requirement is to split the input string( "abc/def/ghi") based on the
> "/" character, get the corresponding value from the external xml and
> then merge them back using "/".
> So the output is expected to be 123/456/789
>
>
> My code :
>
> let $input := "abc/def/ghi"
> return
> for $values in fn:tokenize(($input ),"\/")
> let $value := fn:doc("externalFile.xml")//entry[@code =
> $values]/@value/string()
> return
> fn:string-join(($value),"/")
>
>
> This does not give me the expected result. How do I achieve this. Please
> help.
>
>
> Thanks,
> Sini
>
>
> _______________________________________________
> General mailing list
> [email protected]
> http://developer.marklogic.com/mailman/listinfo/general
>
--
John Snelson, Lead Engineer http://twitter.com/jpcs
MarkLogic Corporation http://www.marklogic.com
_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general