xslt - Xquery to concatenate names if available -
we have incoming message name field below, "givenname" field unbounded:
<name> <surname>louis</surname> <givenname>john</givenname> <givenname>andy</givenname> </name>
we need pass message other end system as:
<name> <fullname>louis, john andy</fullname> </name>
so, if givenname field not present in input, transformation should produce:
<name> <fullname>louis</fullname> </name>
and if multipe givenname present in input should concatenate seperating space.
i tried using concatenate function not giving desired result. tried using:
<ns1:fullname>{ fn:concat($submittedby/ns1:name/ns1:surname,", ", (for $givenname in $submittedby/ns1:name/ns1:givenname return fn:concat(data($givenname), "")) ) }</ns1:fullname>
but producing like:
<name> <fullname>louis, johnandy</fullname> </name>
i having trouble in separating givenname space if present.
could please provide suggestion.
tia,
fn:concat($str1, $str2, ...)
expects single string per argument , concatenates of them 1 string. concatenating sequence of strings , specifying should go between parts, can use fn:string-join($strs, $joiner)
:
string-join(('foo', 'bar', 'baz'), '::')
produces string foo::bar::baz
.
Comments
Post a Comment