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]<mailto:[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]<mailto:[email protected]>
http://developer.marklogic.com/mailman/listinfo/general
_______________________________________________
General mailing list
[email protected]<mailto:[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