Xpath gives multiple results, finding the one originating from the latest imported document?
A quick question, I have this simple xquery to retrieve a node that sometimes has multiple hits, and for this reason I am using the function: head. This gives me the first node that matches the xpath, but is there a way to retrieve the node that originates from the latest imported document? My current query: xquery head (//event[eventID="12345ABC"]) // Sam
Hi Christian, thanks! I don't know if this helps, is data added at the top or bottom? I haven't been able to see a pattern, but if data is added at the bottom, this will probably do it, silly of me not to test last or tail ..... I'll give it a try! // Sam -----Original Message----- From: Christian Grün [mailto:christian.gruen@gmail.com] Sent: den 15 oktober 2014 12:36 To: Sam Eklund Cc: basex-talk@mailman.uni-konstanz.de Subject: Re: [basex-talk] Xpath gives multiple results, finding the one originating from the latest imported document? Hi Sam,
This gives me the first node that matches the xpath, but is there a way to retrieve the node that originates from the latest imported document?
The following query will give you the last node: (//event[eventID="12345ABC"]) [last()] Does this help? Christian
Hi Sam, exactly, added documents will be appended to the end of the database. Things look different if you replace existing documents; in that case, it's not that easy to find out what entries were added after others. Christian On Wed, Oct 15, 2014 at 2:20 PM, Sam Eklund <sam.eklund@gluebox.se> wrote:
Hi Christian, thanks!
I don't know if this helps, is data added at the top or bottom?
I haven't been able to see a pattern, but if data is added at the bottom, this will probably do it, silly of me not to test last or tail .....
I'll give it a try!
// Sam
-----Original Message----- From: Christian Grün [mailto:christian.gruen@gmail.com] Sent: den 15 oktober 2014 12:36 To: Sam Eklund Cc: basex-talk@mailman.uni-konstanz.de Subject: Re: [basex-talk] Xpath gives multiple results, finding the one originating from the latest imported document?
Hi Sam,
This gives me the first node that matches the xpath, but is there a way to retrieve the node that originates from the latest imported document?
The following query will give you the last node:
(//event[eventID="12345ABC"]) [last()]
Does this help? Christian
participants (2)
-
Christian Grün -
Sam Eklund