3 XQuery functions, substring-before
, substring-after
and tokenize
are used to get
the required output.
substring-before
is used to get the Name.
Similarly, the substring-after
is used to get the Job portion.
Then the tokenize
function, is used to split the Jobs.
let $data :=
<E>
<Employee>AAA@A#B#C#D</Employee>
<Employee>BBB@A#B#C#D</Employee>
<Employee>CCC@A#B#C#D</Employee>
<Employee>DDD@A#B#C#D</Employee>
</E>
for $x in $data/Employee
return
<Employee>
{<Name>{substring-before($x,"@")}</Name>}
{<Jobs>{
for $tag in tokenize(substring-after($x,"@"),'#')
return
<Job>{$tag}</Job>
}</Jobs>
}</Employee>
HTH...