Problems with XQuery matching records by compound key
Hi I am trying to match records from two different documents. Match key consists of two parts, so I simply build up a string from first and second match key and separate it by a hypen Here are source documents *Events.xml* <EVENTS>** * *<MSG id=*"{e8e85fdd-04d8-43ea-8090-e72337c3a30d}"* location=*"Prague"* event=*"Christmass"*/>** * *<MSG id=*"{7c94b2fc-b97c-4c09-b694-9993bfb2b93c}"* location=* "Bratislava"* event=*"Easterns"*/>** * *<MSG id=*"{bdbb11da-2c92-425d-9bf5-87c1e96e1bd4}"* location=*"Berlin"* event=*"Berlinale"*/>** </EVENTS>** * * *Reports.xml* <REPORTS>** * *<MSG id=*"{abcd}"* location=*"Prague"* event=*"Christmass"*/>** * *<MSG id=*"{efgh}"* location=*"Bratislava"* event=*"Easterns"*/>** * *<MSG id=*"{ijkl}"* location=*"Paris"* event=*"FassionFest"*/>** * *<MSG id=*"{mnqr}"* location=*"Moscow"* event=*"BalletFestival"*/>** </REPORTS> I am trying to find for each report all events, which are having the same location and event attributes So I build intermediate variables, containing pre-calculated keys And finally I try to find related events *match.xq* (:* *Construct* *matching* *keys* **for** *events* *:)** *let** **$event-msg-keys** *:=* * * *(*for** **$event** **in** */EVENTS/MSG** * **return** * * *<EVENT-MSG id="{$event/@id}" key="{concat($event/@location, '-', $event/@event)}"/>** * *)** * * (:* *Construct* *matching* *keys* **for** *reports* *:)** * * *let** **$report-msg-keys** *:=* * * *(*for** **$report** **in** */REPORTS/MSG* * * **return** * * *<REPORT-MSG id="{$report/@id}" key="{concat($report/@location, '-', $report/@event)}"/>** * *)** * * (:* *Find* *all* *events,* *related* **to** *each* *report:)** *for** **$report-msg** **in** **$report-msg-keys*** *let** **$report-msg-id** *:=* **$report-msg*/@id** *let** **$report-msg-key** *:=* **$report-msg*/@key** * * *let** **$related-events** *:=* * * *(*for** **$event-msg** **in** **$event-msg-keys*** * **where** **$event-msg*/@key* *=* **$report-msg-key*** * **return** **$event-msg*)** * * *return*** <REPORT-MSG id="{$report-msg-id}" key="{$report-msg-key}">** * *<RELATED-EVENTS>{$related-events}</RELATED-EVENTS></REPORT-MSG> However, resulting dokument does not show any related events <REPORT-MSG id=*"{abcd}"* key=*"Prague-Christmass"*>** * *<RELATED-EVENTS/>** </REPORT-MSG>** <REPORT-MSG id=*"{efgh}"* key=*"Bratislava-Easterns"*>** * *<RELATED-EVENTS/>** </REPORT-MSG>** <REPORT-MSG id=*"{ijkl}"* key=*"Paris-FassionFest"*>** * *<RELATED-EVENTS/>** </REPORT-MSG>** <REPORT-MSG id=*"{mnqr}"* key=*"Moscow-BalletFestival"*>** * *<RELATED-EVENTS/>** </REPORT-MSG> *Versions of BaseX* All the time I worked with GUI 1. I started testing on BaseX 6.3.4 2. I used a bit more complex data and query 3. After failing I tried on 6.3.1 4. There I was unable to open the collection with complains about Index out of bound Java error 5. Then I dropped the database and created it again. Trying to run the XQuery I got the same error. 6. returned back to 6.3.4 7. rewrote it to shorted sample, shown above I wonder, what I am doing wrong. Any advice? With best regards Jan Vlčinský
Hi Jan, Am 23.12.2010 16:56, schrieb Jan Vlčinský (CAD):
I wonder, what I am doing wrong. Any advice?
that seems to be a bug. I lack the time to investigate this right now, but here's a minimal example for others to test:
(<foo key='a'/>)[@key = 'a']
When I do this without an open ducument, it runs fine, but with an open collection, this happens:
Compiling: - removing unknown tag/attribute "key" - pre-evaluating () = "a" - Filter expression: removing false() Result: ()
And finally, with an open one-document DB:
Error: Possible bug? Your feedback is welcome: Contact: basex-talk@mailman.uni-konstanz.de Version: BaseX 6.3.5 Java: Sun Microsystems Inc., 1.6.0_22 OS: Windows Vista, amd64 Stack Trace: java.lang.NullPointerException org.basex.query.QueryResources.docNodes(QueryResources.java:215) org.basex.query.QueryResources.data(QueryResources.java:192) org.basex.query.path.NameTest.comp(NameTest.java:61) org.basex.query.path.AxisStep.comp(AxisStep.java:81) org.basex.query.path.AxisPath.compPath(AxisPath.java:160) org.basex.query.path.Path.comp(Path.java:46) org.basex.query.expr.Arr.comp(Arr.java:35) org.basex.query.expr.CmpG.comp(CmpG.java:118) org.basex.query.expr.Preds.comp(Preds.java:47) org.basex.query.expr.Filter.comp(Filter.java:55) org.basex.query.QueryContext.compile(QueryContext.java:208) org.basex.query.QueryProcessor.compile(QueryProcessor.java:82) org.basex.core.cmd.AQuery.query(AQuery.java:75) org.basex.core.cmd.XQuery.run(XQuery.java:22) org.basex.core.Command.run(Command.java:292) org.basex.core.Command.exec(Command.java:274) org.basex.core.Command.execute(Command.java:67) org.basex.gui.GUI.exec(GUI.java:391) org.basex.gui.GUI$5.run(GUI.java:351)
I used the GUI from the current repository revision for testing. Cheers Leo
Hi Leonard Thanks for quick reaction. And for hint how to work around it. I modified my query to specify the collection explicitly and as it can be run without open database, it returns proper results. Thanks *And Merry Christmas to all of you. *It is time to exchange our XML trees to Christmas one. And let queries to this tree brings proper results, you may enjoy. Jan 2010/12/23 Leonard Wörteler <leonard.woerteler@uni-konstanz.de>
Hi Jan,
Am 23.12.2010 16:56, schrieb Jan Vlčinský (CAD):
I wonder, what I am doing wrong. Any advice?
that seems to be a bug. I lack the time to investigate this right now, but here's a minimal example for others to test:
(<foo key='a'/>)[@key = 'a']
When I do this without an open ducument, it runs fine, but with an open collection, this happens:
Compiling: - removing unknown tag/attribute "key" - pre-evaluating () = "a" - Filter expression: removing false() Result: ()
And finally, with an open one-document DB:
Error: Possible bug? Your feedback is welcome: Contact: basex-talk@mailman.uni-konstanz.de Version: BaseX 6.3.5 Java: Sun Microsystems Inc., 1.6.0_22 OS: Windows Vista, amd64 Stack Trace: java.lang.NullPointerException org.basex.query.QueryResources.docNodes(QueryResources.java:215) org.basex.query.QueryResources.data(QueryResources.java:192) org.basex.query.path.NameTest.comp(NameTest.java:61) org.basex.query.path.AxisStep.comp(AxisStep.java:81) org.basex.query.path.AxisPath.compPath(AxisPath.java:160) org.basex.query.path.Path.comp(Path.java:46) org.basex.query.expr.Arr.comp(Arr.java:35) org.basex.query.expr.CmpG.comp(CmpG.java:118) org.basex.query.expr.Preds.comp(Preds.java:47) org.basex.query.expr.Filter.comp(Filter.java:55) org.basex.query.QueryContext.compile(QueryContext.java:208) org.basex.query.QueryProcessor.compile(QueryProcessor.java:82) org.basex.core.cmd.AQuery.query(AQuery.java:75) org.basex.core.cmd.XQuery.run(XQuery.java:22) org.basex.core.Command.run(Command.java:292) org.basex.core.Command.exec(Command.java:274) org.basex.core.Command.execute(Command.java:67) org.basex.gui.GUI.exec(GUI.java:391) org.basex.gui.GUI$5.run(GUI.java:351)
I used the GUI from the current repository revision for testing.
Cheers Leo _______________________________________________ BaseX-Talk mailing list BaseX-Talk@mailman.uni-konstanz.de https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
-- *Ing. Jan Vlčinský* CAD programy Slunečnicová 338/3, 734 01 Karviná Ráj, Czech Republic tel: +420-597 602 024; mob: +420-608 979 040 skype: janvlcinsky; GoogleTalk: jan.vlcinsky@gmail.com http://cz.linkedin.com/in/vlcinsky
Merry BaseX-Mas from the BaseX Team. Am 23.12.10 19:40, schrieb Jan Vlčinský (CAD):
Hi Leonard Thanks for quick reaction. And for hint how to work around it. I modified my query to specify the collection explicitly and as it can be run without open database, it returns proper results.
Thanks
*And Merry Christmas to all of you. *It is time to exchange our XML trees to Christmas one. And let queries to this tree brings proper results, you may enjoy.
Jan
2010/12/23 Leonard Wörteler <leonard.woerteler@uni-konstanz.de <mailto:leonard.woerteler@uni-konstanz.de>>
Hi Jan,
Am 23.12.2010 16:56, schrieb Jan Vlčinský (CAD): > I wonder, what I am doing wrong. Any advice?
that seems to be a bug. I lack the time to investigate this right now, but here's a minimal example for others to test:
> (<foo key='a'/>)[@key = 'a']
When I do this without an open ducument, it runs fine, but with an open collection, this happens:
> Compiling: > - removing unknown tag/attribute "key" > - pre-evaluating () = "a" > - Filter expression: removing false() > Result: ()
And finally, with an open one-document DB:
> Error: Possible bug? Your feedback is welcome: > Contact: basex-talk@mailman.uni-konstanz.de <mailto:basex-talk@mailman.uni-konstanz.de> > Version: BaseX 6.3.5 > Java: Sun Microsystems Inc., 1.6.0_22 > OS: Windows Vista, amd64 > Stack Trace: > java.lang.NullPointerException > org.basex.query.QueryResources.docNodes(QueryResources.java:215) > org.basex.query.QueryResources.data(QueryResources.java:192) > org.basex.query.path.NameTest.comp(NameTest.java:61) > org.basex.query.path.AxisStep.comp(AxisStep.java:81) > org.basex.query.path.AxisPath.compPath(AxisPath.java:160) > org.basex.query.path.Path.comp(Path.java:46) > org.basex.query.expr.Arr.comp(Arr.java:35) > org.basex.query.expr.CmpG.comp(CmpG.java:118) > org.basex.query.expr.Preds.comp(Preds.java:47) > org.basex.query.expr.Filter.comp(Filter.java:55) > org.basex.query.QueryContext.compile(QueryContext.java:208) > org.basex.query.QueryProcessor.compile(QueryProcessor.java:82) > org.basex.core.cmd.AQuery.query(AQuery.java:75) > org.basex.core.cmd.XQuery.run(XQuery.java:22) > org.basex.core.Command.run(Command.java:292) > org.basex.core.Command.exec(Command.java:274) > org.basex.core.Command.execute(Command.java:67) > org.basex.gui.GUI.exec(GUI.java:391) > org.basex.gui.GUI$5.run(GUI.java:351)
I used the GUI from the current repository revision for testing.
Cheers Leo _______________________________________________ BaseX-Talk mailing list BaseX-Talk@mailman.uni-konstanz.de <mailto:BaseX-Talk@mailman.uni-konstanz.de> https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
-- *Ing. Jan Vlčinský* CAD programy Slunečnicová 338/3, 734 01 Karviná Ráj, Czech Republic tel: +420-597 602 024; mob: +420-608 979 040 skype: janvlcinsky; GoogleTalk: jan.vlcinsky@gmail.com <mailto:jan.vlcinsky@gmail.com> http://cz.linkedin.com/in/vlcinsky
_______________________________________________ BaseX-Talk mailing list BaseX-Talk@mailman.uni-konstanz.de https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
Hi Jan, thanks Leo, the bug has been fixed and committed to the repository. Merry X, Christian ___________________________
Hi Jan,
Am 23.12.2010 16:56, schrieb Jan Vlčinský (CAD):
I wonder, what I am doing wrong. Any advice?
that seems to be a bug. I lack the time to investigate this right now, but here's a minimal example for others to test:
(<foo key='a'/>)[@key = 'a']
When I do this without an open ducument, it runs fine, but with an open collection, this happens:
Compiling: - removing unknown tag/attribute "key" - pre-evaluating () = "a" - Filter expression: removing false() Result: ()
And finally, with an open one-document DB:
Error: Possible bug? Your feedback is welcome: Contact: basex-talk@mailman.uni-konstanz.de Version: BaseX 6.3.5 Java: Sun Microsystems Inc., 1.6.0_22 OS: Windows Vista, amd64 Stack Trace: java.lang.NullPointerException org.basex.query.QueryResources.docNodes(QueryResources.java:215) org.basex.query.QueryResources.data(QueryResources.java:192) org.basex.query.path.NameTest.comp(NameTest.java:61) org.basex.query.path.AxisStep.comp(AxisStep.java:81) org.basex.query.path.AxisPath.compPath(AxisPath.java:160) org.basex.query.path.Path.comp(Path.java:46) org.basex.query.expr.Arr.comp(Arr.java:35) org.basex.query.expr.CmpG.comp(CmpG.java:118) org.basex.query.expr.Preds.comp(Preds.java:47) org.basex.query.expr.Filter.comp(Filter.java:55) org.basex.query.QueryContext.compile(QueryContext.java:208) org.basex.query.QueryProcessor.compile(QueryProcessor.java:82) org.basex.core.cmd.AQuery.query(AQuery.java:75) org.basex.core.cmd.XQuery.run(XQuery.java:22) org.basex.core.Command.run(Command.java:292) org.basex.core.Command.exec(Command.java:274) org.basex.core.Command.execute(Command.java:67) org.basex.gui.GUI.exec(GUI.java:391) org.basex.gui.GUI$5.run(GUI.java:351)
I used the GUI from the current repository revision for testing.
Cheers Leo _______________________________________________ BaseX-Talk mailing list BaseX-Talk@mailman.uni-konstanz.de https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
participants (4)
-
Andreas Weiler -
Christian Grün -
Jan Vlčinský (CAD) -
Leonard Wörteler