hi,

I was able to do this.

Code :


let $order := 'Name;Date;Status;PDF'
let $columnOrder := fn:tokenize($order,';')
for $result in $results/result
  return element result {
                for $order in $columnOrder
              ?  return  functx:dynamic-path($result,$order)
}


Thanks

Pragya

________________________________
From: [email protected] 
<[email protected]> on behalf of Kapoor, Pragya 
<[email protected]>
Sent: Friday, February 6, 2015 3:13 PM
To: MarkLogic Developer Discussion
Subject: [MarkLogic Dev General] Custom ordering of results


Hi,


I have a requirement where in I have to return the results in user preference 
order.


Currently the order of the xml element is fixed :


<results>

    <result>
        <PDF>/pdfs/0000025.pdf</PDF>
        <Name>ABC</Name>
        <Date>2015-01-01</Date>
        <Status>Active</Status>
    </result>
    <result>
        <PDF>/pdfs/0000028.pdf</PDF>
        <Name>XYZ</Name>
        <Date>2015-01-07</Date>
?        <Status>Terminated</Status>
    </result>
</results>


Now I need to return the results in the below order (or Custom Order):


let $columnOrder := Name;Date;Status;PDF


So ,the output should be like:

<results>

    <result>
        <Status>Active</Status>
        <Name>ABC</Name>
       <PDF>/pdfs/0000025.pdf</PDF>
        <Date>2015-01-01</Date>
     </result>
    <result>
?       <Status>Terminated</Status>
        <Name>XYZ</Name>
       <PDF>/pdfs/0000028.pdf</PDF>?
        <Date>2015-01-017</Date>
    </result>
</results>

Let me know, how can I achieve this.

Thanks
Pragya



"This e-mail and any attachments transmitted with it are for the sole use of 
the intended recipient(s) and may contain confidential , proprietary or 
privileged information. If you are not the intended recipient, please contact 
the sender by reply e-mail and destroy all copies of the original message. Any 
unauthorized review, use, disclosure, dissemination, forwarding, printing or 
copying of this e-mail or any action taken in reliance on this e-mail is 
strictly prohibited and may be unlawful."
"This e-mail and any attachments transmitted with it are for the sole use of 
the intended recipient(s) and may contain confidential , proprietary or 
privileged information. If you are not the intended recipient, please contact 
the sender by reply e-mail and destroy all copies of the original message. Any 
unauthorized review, use, disclosure, dissemination, forwarding, printing or 
copying of this e-mail or any action taken in reliance on this e-mail is 
strictly prohibited and may be unlawful."
_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to