From: Adam R. <ad...@ex...> - 2011-10-06 20:09:40
|
You are correct in your understanding of the XQuery spec, and I could easily make this change and probably should. But I do wonder how many people rely on this existing bad behaviour. Its tricky because eXist-db has no notion of both 'XML Documents' and 'Binary documents'. Perhaps we should start referring to Binary documents as Binary resources. I am reluctant to fix this, because calling doc-available() and getting true() for a URI that points to a binary resource makes perfect sense to me. Unfortunately its not compliant with the specification, however the specification has no consideration whatsoever of Binary documents/resources because its the XML Query specification. We perhaps need an xmldb:doc-exists() function to replace this once we bring fn:doc-available() inline with the specs. 2011/10/6 Вячеслав Седов <sch...@gm...> > hi, > > if (doc-available($file-name)) then doc($file-name) else > util:binary-doc($file-name) (: where $file-name point to xquery module > :) produce error like this > > Document /db/test/backup.xq is a binary resource, not an XML > document. Please consider using the function util:binary-doc() to > retrieve a reference to it. > > but here http://www.w3.org/TR/xpath-functions/#func-doc-available > > we can see > > "15.5.5 fn:doc-available > > fn:doc-available($uri as xs:string?) as xs:boolean > Summary: The function returns true if and only if the function call > fn:doc($uri) would return a document node. > > If $uri is an empty sequence, this function returns false. > > If a call on fn:doc($uri) would return a document node, this function > returns true. > > If $uri is not a valid URI according to the rules applied by the > implementation of fn:doc, an error is raised [err:FODC0005]. > > Otherwise, this function returns false. > > If this function returns true, then calling fn:doc($uri) within the > same ·execution scope· must return a document node. However, if > non-stable processing has been selected for the fn:doc function, this > guarantee is lost." > > with best wishes, > Slav > > > ------------------------------------------------------------------------------ > All the data continuously generated in your IT infrastructure contains a > definitive record of customers, application performance, security > threats, fraudulent activity and more. Splunk takes this data and makes > sense of it. Business sense. IT sense. Common sense. > http://p.sf.net/sfu/splunk-d2dcopy1 > _______________________________________________ > Exist-development mailing list > Exi...@li... > https://lists.sourceforge.net/lists/listinfo/exist-development > -- Adam Retter eXist Developer { United Kingdom } ad...@ex... irc://irc.freenode.net/existdb |