Hi Smith

Follow the example might help you

/sample1.xml 

<root>
        <state>USA</state>
        <state>WB</state>
        <state>CAN</state>
        <country>IN</country>
        <country>ARGN</country>
</root>

let $x := fn:index-of(doc("/sample1.xml")//state,"USA")
return
doc("/sample1.xml")//state[$x+2]

The above query assigned the index of USA in $x and the search for the 
element value next to it.

Let me know If some deviations from your original thought.

Regards
Abhishek Srivastav
Systems Engineer
Tata Consultancy Services
Cell:- +91-9883389968
Mailto: [email protected]
Website: http://www.tcs.com
____________________________________________
Experience certainty.   IT Services
                        Business Solutions
                        Outsourcing
____________________________________________



From:
Randy Smith <[email protected]>
To:
[email protected]
Date:
05/10/2011 02:16 AM
Subject:
[MarkLogic Dev General] How To Get The "Content" of An Index?
Sent by:
[email protected]



Anyone,
I think this is a simple question:
If I am using the MarkLogic search API like like with the Top-Songs app we 
developed in class e.g.:

let $items := 
    for $song in $results/search:result
    let $song-doc := fn:doc($uri)
    return

        {if {$song-doc//ts:Value[.='cat'])
            then <div class="abc"> Get the index of "Value" that has "cat" 
in it ==> {fn:index-of($song-doc//ts:Value/text(), 'cat')}</div>
    else ()} ...

The above works fine and gives me back the index for "cat" that is one of 
the many content values in element "Value" (the element "Value" appears as 
many as 1500 times in some documents).
But what I need is the content of the index+1 position. I already know 
"cat" is in the returned index position but I need to print out the 
content of the index + 1 position (or in some cases index+2)

I'm sure there is a nice way to reference the $song-doc//ts:Value[.='cat'] 
content by using something like (but I know this does not work)  
$song-doc//ts:Value[index+1] to get the content printed out. I know to 
look for "cat" but I do not know what is in the "cat" position + 1.

Any help appreciated!  :'( _______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general


=====-----=====-----=====
Notice: The information contained in this e-mail
message and/or attachments to it may contain 
confidential or privileged information. If you are 
not the intended recipient, any dissemination, use, 
review, distribution, printing or copying of the 
information contained in this e-mail message 
and/or attachments to it are strictly prohibited. If 
you have received this communication in error, 
please notify us by reply e-mail or telephone and 
immediately and permanently delete the message 
and any attachments. Thank you


_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to