Xpath gives multiple results, finding the one originating from the latest imported document?
Wednesday, 15 October 2014 · 4 messages
SE
Sam Eklund15 Oct 2014 11:28 #
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
CG
Christian Grün15 Oct 2014 12:36 #
Hi Sam,
Quoted text · Sam Eklund · 1 line
> 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
SE
Sam Eklund15 Oct 2014 14:20 #
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
Quoted text · Christian Grün · 12 lines
-----Original Message----- From: Christian Grün [mailto:christian.gruen at gmail.com] Sent: den 15 oktober 2014 12:36 To: Sam Eklund Cc: basex-talk at 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
CG
Christian Grün15 Oct 2014 14:31 #
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
Quoted text · Sam Eklund · 28 lines
On Wed, Oct 15, 2014 at 2:20 PM, Sam Eklund <sam.eklund at 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 at gmail.com] > Sent: den 15 oktober 2014 12:36 > To: Sam Eklund > Cc: basex-talk at 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
Written for BaseX 7.9. BaseX may have changed since: please check the current documentation.
⚡Generated with XQuery