Christian,
Thanks for all your support.
I picked the latest snapshot as advised. For simple queries it worked !
However, below query didn't work:
~/Downloads/basex/bin/basex -bn='/Archives/*//class[contains(@name,"abc") and contains(@name,"pqr")]' get_paths.xq Stopped at /Users/mansiadmin/Documents/Research-Projects/BigData, 1/4: [XPDY0002] and: no context value bound.
However, below query works as a charm:
~/Downloads/basex/bin/basex -bn='/Archives/*//class[contains(@name,"abc")]' get_paths.xq
I am hoping, for first query above, its some syntactic issue at my end. But, couldn't fix it, so thought should point out. Please advise.
Code:
declare variable $n as xs:string external; declare option output:item-separator "
";
let $aPath := for $db in db:list() let $query := "declare variable $db external; " || "db:open($db)" || $n return xquery:eval($query, map { 'db': $db, 'query': $n })
let $paths := for $elem in $aPath return db:path($elem)
return distinct-values($paths)
On Mon, Nov 3, 2014 at 6:48 PM, Christian Grün christian.gruen@gmail.com wrote:
…in the meanwhile, could you please check if the bug has possibly been fixed in the latest 8.0 snapshot [1]?
[1] http://files.basex.org/releases/latest
On Tue, Nov 4, 2014 at 12:46 AM, Christian Grün christian.gruen@gmail.com wrote:
Improper use? Potential bug? Your feedback is welcome:
Sounds like a little bug indeed; I will check it tomorrow!
Contact: basex-talk@mailman.uni-konstanz.de Version: BaseX 7.9 Java: Oracle Corporation, 1.7.0_45 OS: Mac OS X, x86_64 Stack Trace: java.lang.NullPointerException at org.basex.query.value.item.Str.get(Str.java:49) at org.basex.query.func.FNDb.path(FNDb.java:489) at org.basex.query.func.FNDb.item(FNDb.java:128) at org.basex.query.expr.ParseExpr.iter(ParseExpr.java:45) at org.basex.query.func.FNDb.iter(FNDb.java:92) at org.basex.query.gflwor.GFLWOR$2.next(GFLWOR.java:78) at org.basex.query.MainModule$1.next(MainModule.java:98) at org.basex.core.cmd.AQuery.query(AQuery.java:91) at org.basex.core.cmd.XQuery.run(XQuery.java:22) at org.basex.core.Command.run(Command.java:329) at org.basex.core.Command.execute(Command.java:94) at org.basex.server.LocalSession.execute(LocalSession.java:121) at org.basex.server.Session.execute(Session.java:37) at org.basex.core.CLI.execute(CLI.java:106) at org.basex.BaseX.<init>(BaseX.java:123) at org.basex.BaseX.main(BaseX.java:42)
On Thu, Oct 30, 2014 at 5:54 AM, Christian Grün <
christian.gruen@gmail.com>
wrote:
Hi Mansi,
you have been close! It could work with the following query (I haven't tried it out, though):
_ get_query_result.xq ____________________
declare variable $n external; declare option output:item-separator "
";
let $aList := for $name in db:list() let $db := db:open($name) return xquery:eval($n, map { '': $db })
return distinct-values($aList) ______________________________________
In this code, I'm opening the database in the main loop, and I then bind it to the empty string. This way, the database will be the context of the query to be evaluated query, and you won't have to deal with bugs that arise from the concatenation of "db:open" and the query string.
- Can we assign dynamic values as a value to a map's key ?
- Can I map have more than one key, in query:eval ?
This is both possible. As you see in the following query, you'll again have to declare the variables that you want to bind. I agree this causes a lot of code, so we may simplify it again in a future version of BaseX: ______________________________________
let $n := "/a/b/c" for $db in db:list() let $query := "declare variable $db external; " || "db:open($db)" || $n return xquery:eval($query, map { 'db': $db, 'query': $n }) ______________________________________
Best, Christian
--
- Mansi