From: Alister P. <ali...@ma...> - 2007-12-07 06:08:14
|
Hi, From the docs: document-uri($a) Returns the absolute URI of the resource from which the document node $a was constructed, if none such URI exists returns the empty sequence. If $a is the empty sequence, returns the empty sequence. So you must provide the "document-node". Try changing your original query to use the root() function: document-uri(root($ver)) Also, you could improve the expression by writing (ignoring namespaces for clarity): let $books := collection("/db/testA/testB/Books/2007/09/18/ABC/")/ Books (: all the Books in the collection :) let $maxVer := max($books/ElmentB/@VersionNum) let $docContainingMaxVersion := $books[ElmentB/@VersionNum eq xs:string($maxVer)] return document-uri(root($docContainingMaxVersion)) I tested this on the latest code using a similar query: ( I have a collection of documents containing post-codes ). let $post-codes := collection('/db/pekoe/resources/postcodes')/post- codes let $maxpc := max($post-codes/pc/code) return document-uri(root($post-codes[pc/code eq xs:string($maxpc)])) Regards, Alister. On 07/12/2007, at 3:44 PM, d s wrote: > I think document-uri doesn't work in the revision 7027 > or is there something wrong with my query? > > I tried this query below: > > for $ver in document("/db/testA/2007/11/08/test.xml") > return document-uri($ver) > > It works on the old version. It should return result --> /db/testA/ > 2007/11/08/test.xml > > Cheers, > > > ----- Original Message ---- > From: d s <mis...@ya...> > To: exi...@li... > Sent: Friday, December 7, 2007 2:31:05 PM > Subject: [Exist-open] XQuery problem > > Hi, > > I wonder if someone can notice what's the problem with my query > > I'm trying to get the filename of the file which have the maximum > of VersionNum in ElementB. > I have 2 version of exist. The query is working with the old > version (I downloaded around 3 months ago and it's on localhost). > But the query doesn't work with eXist rev7027 December 4, 2007 > 20:47 (I'm currently running this on another remote server). > There's no error, it's just returned nothing. > > Below is my data example: > > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > SchemaVersion="1.1" > xsi:schemaLocation="http://www.foo.com/FooSchem > exSchema.xsd"> > <ElmentA ID="ABC">HELLO WORLD</ElmentA> > <ElmentB ID="ID0000047" VersionNum="274716" > CompileDateTime="2007-09-17T17:01:02">hello world element B</ElmentB> > <ElmentC xsi:type="programmeScheduleType" UTCOffset="+10:00" > StartDateTime="2007-09-18T00:00:00"> > <ElementCA> > <ElementCATitle>Station Close</ElementCATitle> > <ElementCADesc>Entertainment</ElementCADesc> > ... > </ElementCA> > </ElementC> > </Books> > > and my query is: > declare namespace ns1="http://www.foo.com/FooSchem"; > > max(for $ver in collection("/db/testA/testB/Books/2007/09/18/ > ABC/")//ns1:ElmentB/@VersionNum return document-uri($ver)) > > Thanks for your help :) > > Never miss a thing. Make Yahoo your homepage. > > > Be a better friend, newshound, and know-it-all with Yahoo! Mobile. > Try it now. > ---------------------------------------------------------------------- > --- > SF.Net email is sponsored by: > Check out the new SourceForge.net Marketplace. > It's the best place to buy or sell services for > just about anything Open Source. > http://sourceforge.net/services/buy/ > index.php_______________________________________________ > Exist-open mailing list > Exi...@li... > https://lists.sourceforge.net/lists/listinfo/exist-open |