Geert, I don’t think fn:base-uri is actually what you’re looking for. In this case, it happens to coincide with the document URI. However, in general, base URIs are mutable for individual nodes, even within the same document. For example, when resolving XInclude links, you could use the base URI on the “expanded” (i.e. resolved) node to indicate where it came from and, perhaps, how to resolve any nested links. (This is, in fact, what the built-in Modular Document functions do <http://developer.marklogic.com/pubs/4.0/apidocs/XInclude.html>.) In this case, the base URI would not necessarily be the same as the URI of the document (node). I’d recommend xdmp:node-uri <http://developer.marklogic.com/pubs/4.1/apidocs/Extension.html#xdmp:node-uri>.
Justin Justin Makeig Product Manager Mark Logic Corporation 999 Skyway Road Suite 200 San Carlos, CA 94070 +1 650 655 2387 Phone [email protected]<mailto:[email protected]> www.marklogic.com<http://www.marklogic.com> <http://www.marklogic.com/><http://www.marklogic.com/> This e-mail and any accompanying attachments are confidential. The information is intended solely for the use of the individual to whom it is addressed. Any review, disclosure, copying, distribution, or use of this e-mail communication by others is strictly prohibited. If you are not the intended recipient, please notify us immediately by returning this message to the sender and delete all copies. Thank you for your cooperation. -----Original Message----- From: [email protected] [mailto:[email protected]] On Behalf Of Geert Josten Sent: Wednesday, January 20, 2010 1:20 PM To: General Mark Logic Developer Discussion Subject: RE: [MarkLogic Dev General] question about cts:search Hi Helen, I personally prefer base-uri, as it navigates up to the root itself if necessary. You can read more about the two functions here: http://developer.marklogic.com/pubs/4.1/apidocs/AccessorBuiltins.html#fn:document-uri (particularly read Summary and User Notes) Kind regards, Geert > -----Original Message----- > From: [email protected] > [mailto:[email protected]] On Behalf Of > Helen Chen > Sent: woensdag 20 januari 2010 22:05 > To: General Mark Logic Developer Discussion > Cc: Helen Chen > Subject: Re: [MarkLogic Dev General] question about cts:search > > Hi Geert, > > I run your query > for $doc in doc()/ns1:article//ns1:sub[not(@temp1 or @temp2)] > let $uri := try { base-uri($doc) } catch ($e) { () } where > not($uri) return > $doc > > and it returns empty sequence. > ------------ > > if I take "not" out in the where clause, like for $doc in > doc()/ns1:article//ns1:sub[not(@temp1 or @temp2)] let $uri := > try { base-uri($doc) } catch ($e) { () } where ($uri) return > $doc > > I got 7 nodes out, these nodes only have attributes, no sub > nodes inside, like <ns1:sub file="1"/>, and they are all in > the same xml file, the xml is: /pt/ajr_1.xml > > -------------- > I actually can run > > doc()/ns1:article//ns1:sub[not(@temp1 or @temp2)]/fn:root(.) > > and it returns the root of file /pt/ajr_1.xml, and only one > result node > > --------- > but I cannot run > doc()/ns1:article//ns1:sub[not(@temp1 or @temp2)]/fn:document- > uri(fn:root(.)) > > > I thought it was because of multiple node returned, but when I use > fn:root(.) at the end, it returns only one node, so it must be > something else. > > when I do : doc()/ns1:article//ns1:sub[not(@temp1 or @temp2)]/ > fn:document-uri(.) > it returns empty sequence > > when I do: doc()/ns1:article//ns1:sub[not(@temp1 or @temp2)]/ > fn:document-uri(fn:root(.)) > it gives error > > when I do: doc()/ns1:article//ns1:sub[not(@temp1 or @temp2)]/ > fn:document-uri(fn:root(.)/ns1:article) > this query makes sure only one node for > fn:document-uri() function, but it returns empty sequence > > It seems that fn:root() pass root element to the > fn:document-uri() and > it does not like it, if I pass node to it, it returns empty > sequence. > Can we use fn:document-uri() or fn:base-uri() at the end of query? > > > Thanks, Helen > > > On Jan 20, 2010, at 3:33 PM, Geert Josten wrote: > > > Hi Helen, > > > >> I changed and I got the same error as when I use fn:base-uri(.) > >> > >> Description: XDMP-NOTANODE: doc()/child::ns1:article/ > >> descendant::ns1:sub[not(attribute::temp1 or > >> attribute::temp2)]/document-uri(root(.)) -- > >> xs:anyURI("/pt/ajr_1.xml") is not a node > >> > >> The result is really only one document, but it seems that > I cannot > >> put > >> fn:document-uri at the end of the query. > > > > This is actually quite strange. Doc() always returns nodes > or empty > > sequence, child always returns nodes or empty sequence, descendant > > always returns nodes or empty sequence, so this is very > odd. Even a > > text or binary document would result in a node. > > > > Could you try the following to figure out which document is > causing > > the trouble? > > > > for $doc in doc()/ns1:article//ns1:sub[not(@temp1 or @temp2)] > > let $uri := try { base-uri($doc) } catch ($e) { () } > > where not($uri) > > return > > $doc > > > > Kind regards, > > Geert > > > > > > Drs. G.P.H. Josten > > Consultant > > > > > > http://www.daidalos.nl/ > > Daidalos BV > > Source of Innovation > > Hoekeindsehof 1-4 > > 2665 JZ Bleiswijk > > Tel.: +31 (0) 10 850 1200 > > Fax: +31 (0) 10 850 1199 > > http://www.daidalos.nl/ > > KvK 27164984 > > De informatie - verzonden in of met dit emailbericht - is > afkomstig > > van Daidalos BV en is uitsluitend bestemd voor de geadresseerde. > > Indien u dit bericht onbedoeld hebt ontvangen, verzoeken wij u het > > te verwijderen. Aan dit bericht kunnen geen rechten worden ontleend. > > > > > > > > _______________________________________________ > > General mailing list > > [email protected] > > http://xqzone.com/mailman/listinfo/general > > _______________________________________________ > General mailing list > [email protected] > http://xqzone.com/mailman/listinfo/general > _______________________________________________ General mailing list [email protected] http://xqzone.com/mailman/listinfo/general
_______________________________________________ General mailing list [email protected] http://xqzone.com/mailman/listinfo/general
