I was writing up a question I had (see below), when I found the answer (at the very bottom of this post). I decided to post my question anyway in the hope that it might help somebody.
=== original question === Hi-- I'm working in an environment where I have XML documents in a single collection, named 'brain'. Now I want to do a query on just those XML elements within a given document, which is named in Sedna as 't'. You can see it in the following (this is from a Clojure REPL): --- infwb.core> (db/SYSpeek-into-db) ["<documents><document name=\"$db_security_data\"/><collection name=\"$modules\"/><collection name=\"api\"/><collection name=\"daily\"><document name=\"t\"/></collection><collection name=\"test\"/></documents>"] --- Here is the XQuery string for a query that works: --- "declare default element namespace 'http://infoml.org/infomlFile'; for $base in collection('daily')/infomlFile/infoml[@cardId = 'gw667_110929221638791'] return ($base/data/title/string(), $base/data/content/string(), $base/selectors/tag/string())" --- "@cardId = 'gw667_110929221638791'" describes an infoml element in file t. This query returns a correct result: --- infwb.core> (db/docquery) ["title 2" "content 2" "tag 2"] --- ### Here's my question ### I want to do queries based on the filename, not the collection. Is that possible? To do this, I use the same query but I made minimal changes to it, replacing the substring "in collection ('daily')" with "in doc('t')", as given in the following query string: --- "declare default element namespace 'http://infoml.org/infomlFile'; for $base in doc('t')/infomlFile/infoml[@cardId = 'gw667_110929221822843'] return ($base/data/title/string(), $base/data/content/string(), $base/selectors/tag/string())" --- This returned the following: --- SEDNA Message: ERROR SE4611 There is no transaction to roll back --- I've tried various substitutions, including "in collection ('daily')/doc('t')" . Does anybody know how to do this? I've spent several hours, with no positive results, and an XQuery reference book offers no clues. Thanks. === end of question post === === THE ANSWER === The correct substitution is "in doc('t', 'daily')". Note to Sedna people: I found the solution at http://www.sedna.org/progguide/ProgGuidesu8.html. In particular, in the following text: --- To access a single document from collection in an XQuery or XML update query, the document function accepts a collection name as its second optional argument: doc($doc as xs:string, $col as xs:string) as document-node() --- However, I first tried: --- doc($doc as 't', $col as 'daily') as document-node() --- then I tried: --- doc($doc as 't', $col as 'daily') --- before I finally tried: --- doc('t', 'daily') --- As Ivan knows, I have had this kind of problem before. The solution is either: 1) show examples; 2) explain your notation; or 3) change your notation to something standard so that most users can interpret the notation correctly. Thanks for Sedna, as always, but this kind of problem wastes time unnecessarily. I've begun looking at other XML databases in the hope of finding one that doesn't have pain points like this. Best wishes, Gregg ------------------------------------------------------------------------------ All of the data generated in your IT infrastructure is seriously valuable. Why? It contains a definitive record of application performance, security threats, fraudulent activity, and more. Splunk takes this data and makes sense of it. IT sense. And common sense. http://p.sf.net/sfu/splunk-d2dcopy2 _______________________________________________ Sedna-discussion mailing list Sedna-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sedna-discussion