Hi Pragya,

Please find the below query :


let $input :=
                                                <p>
                <q>
                  <o>pragya</o>
                  <o>kapoor</o>
                </q>
                <q>
                  <o>pragya</o>
                  </q>
                <q>
                  <o>kapoor</o>
                  </q>
                <q>
                  <o>amit</o>
                                                                </q>
                                                </p>

let $output := <p>{
for $each in fn:distinct-values($input//q/o)
let $b := $input//q[o[.=$each]]
let $count := count($input//q/o[.=$each])
return <o count="{$count}">{$each}</o>
}</p>
return $output

Regards,
Asit Nautiyal

From: [email protected] 
[mailto:[email protected]] On Behalf Of Pragya Kapoor
Sent: Tuesday, August 20, 2013 9:54 AM
To: [email protected]
Subject: [MarkLogic Dev General] String array

Hi,

I  want to do the following:

Input
<p>
                <q>
                  <o>pragya</o>
                <o>kapoor</o>
                </q>
                <q>
                  <o>pragya</o>
                  </q>
                <q>
                  <o>kapoor</o>
                  </q>
                <q>
                  <o>amit</o>
  </q>

</p>

Output :
<p>
                                           <o count ="2">pragya"</o>
          <o count ="2">kapoor"</o>
          <o count ="1">amit"</o>

</p>

Thanks
Pragya

**************** CAUTION - Disclaimer *****************

This e-mail contains PRIVILEGED AND CONFIDENTIAL INFORMATION intended solely

for the use of the addressee(s). If you are not the intended recipient, please

notify the sender by e-mail and delete the original message. Further, you are 
not

to copy, disclose, or distribute this e-mail or its contents to any other 
person and

any such actions are unlawful. This e-mail may contain viruses. Infosys has 
taken

every reasonable precaution to minimize this risk, but is not liable for any 
damage

you may sustain as a result of any virus in this e-mail. You should carry out 
your

own virus checks before opening the e-mail or attachment. Infosys reserves the

right to monitor and review the content of all messages sent to or from this 
e-mail

address. Messages sent to or from this e-mail address may be stored on the

Infosys e-mail system.

***INFOSYS******** End of Disclaimer ********INFOSYS***


This e-mail and any files transmitted with it are for the sole use of the 
intended recipient(s) and may contain confidential and privileged information. 
If you are not the intended recipient(s), please reply to the sender and 
destroy all copies of the original message. Any unauthorized review, use, 
disclosure, dissemination, forwarding, printing or copying of this email, 
and/or any action taken in reliance on the contents of 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