Hi,
You can simply find out the position of a node

let $x :=

<languages>
    <language iso3="ita"/>
    <language iso3="fra"/>
    <language iso3="slv"/>
    <language iso3="deu"/>
    <language iso3="eng"/>
</languages>
let $count := 0
return
 for $each in $x/language
     return
          (
          if(fn:data($each/@iso3) = "eng")
          then $count+1
          else(),
          xdmp:set($count,$count+1)

          )

     just replace "eng " by any of the value (like "fra" or "ita" or any)
and you will get the position of that node.


On Fri, May 10, 2013 at 11:50 AM, William Merritt Sawyer <
[email protected]> wrote:

>  You can also do it without the or in the predicate by comparing to a
> sequence of locales you want to match on.****
>
> -Will****
>
> ** **
>
> let $x :=****
>
>
> <languages>
>     <language iso3="ita"/>
>     <language iso3="fra"/>
>     <language iso3="slv"/>
>     <language iso3="deu"/>
>     <language iso3="eng"/>
> </languages>****
>
> return****
>
> ($x/language[@iso3 = ("fra", "eng")])[1]****
>
> ** **
>
> *From:* [email protected] [mailto:
> [email protected]] *On Behalf Of *sini narayanan
> *Sent:* Friday, May 10, 2013 12:17 AM
> *To:* MarkLogic Developer Discussion
> *Subject:* Re: [MarkLogic Dev General] xquery - get position of a node****
>
> ** **
>
> Thanks. It was helpful. ****
>
> ** **
>
> Regards,****
>
> Sini****
>
> ** **
>
> On Fri, May 10, 2013 at 11:33 AM, Fahad Khan <[email protected]> wrote:
> ****
>
> Hi,
>
> To get the first available language "fra" or "eng", I would use:
>
> let $x :=****
>
>
> <languages>
>     <language iso3="ita"/>
>     <language iso3="fra"/>
>     <language iso3="slv"/>
>     <language iso3="deu"/>
>     <language iso3="eng"/>
> </languages>****
>
> return ($x/language[@iso3="fra" or @iso3="eng"])[1]
>
> If you really want the position, something like:
>
> ($x/language[@iso3="fra" or
> @iso3="eng"])[1]/fn:count(preceding-sibling::language) + 1
>
> Hope that helps.
>
> Cheers,
>
> Fahad.****
>
>
>
> On 05/10/2013 06:52 AM, sini narayanan wrote:****
>
>   Hi All,****
>
> ** **
>
> I have an xml document with different language nodes.****
>
> ** **
>
> for example:****
>
> ** **
>
> <languages>****
>
>     <language iso3="ita"/>****
>
>     <language iso3="fra"/>****
>
>     <language iso3="slv"/>****
>
>     <language iso3="deu"/>****
>
>     <language iso3="eng"/>****
>
> </languages>****
>
> ** **
>
> I need to fid out, the first available language "fra" or "eng". (If "fra"
> node comes first or "eng" comes first)****
>
> ** **
>
> Which is the best way to do this ?****
>
> Is ther a way to get the position of a node in xquery?****
>
> ** **
>
> 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****
>
> ** **
>
>
>
> NOTICE: This email message is for the sole use of the intended
> recipient(s) and may contain confidential and privileged information. Any
> unauthorized review, use, disclosure or distribution is prohibited. If you
> are not the intended recipient, please contact the sender by reply email
> and destroy all copies of the original message.****
>
>
> _______________________________________________
> General mailing list
> [email protected]
> http://developer.marklogic.com/mailman/listinfo/general
>
>


-- 
Nitin Kr Jha
Software Engineer
ITO

-- 

"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