for $field in $doc//field
return <output>{fn:string-join(($field/(A,B), if($field/C eq 'z') then
'012' else if($field/C eq 'x') then '098' else $field/C))}</output>

John


On Wed, Sep 4, 2013 at 9:33 AM, sini narayanan <[email protected]>wrote:

> Hi All,
>
> I have an xml file with the following structure
> <fields>
> <field>
>  <A>abc</A>
>  <B>def</B>
>  <C>z</C>
> </field>
> <field>
>  <A>abc</A>
>  <B>def</B>
>  <C>x</C>
> </field>
> </fields>
>
> For each of the field nodes, I need to generate the output as the node
> value of all the child nodes under a field node.
> ie: <output>abcdefz</output>
>   <output>abcdefx</output>
>
> This I can simply get it using the string() value.
>
> let $doc := doc("/Test/file.xml")
> for $i in $doc//fields/field
> return
> <output>{$i/string()}</output>
>
> But here I need an extra processing to be done only for node <C>. ie.
> based on the node value of C node, i need to perform a translation.
> If C/text() eq z then 012 should be the output and if C/text() eq x then
> 098 should be the output.
>
> So the final output expected is
> <output>abcdef012</output>
> <output>abcdef098</output>
>
> How do I achieve this easily in the code that I mentioned earlier.
>
> Thanks,
> Sini
>
> _______________________________________________
> General mailing list
> [email protected]
> http://developer.marklogic.com/mailman/listinfo/general
>
>
_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to