[XPTY0004] Item expected, sequence found

Friday, 3 March 2017 · 8 messages · last reply 8 Mar 2017
BV
Bram Vanroy3 Mar 2017 12:19 #
Hi BaseX peeps I'm running BaseX 8.6.1 on Windows, and I'm running into an issue I can't explain. I am using BaseX to run some benchmarks. As a benchmark I am running different XPath structures to match on the same database. In other words, in a file of a hundred lines each line is an XPath structure, and with Perl I query each line and measure the time it takes. Simple enough, right? The strange thing is that my script runs fine but it crashes on line 17, which is this XPath code: //node[@cat="pp" and node[@rel="hd" and @pt="vz" and number(@begin) < number(../node[@rel="obj1" and @cat="np"]/node[@rel="mod" and @cat="pp"]/node[@rel="hd" and @pt="vz"]/@begin)] and node[@rel="obj1" and @cat="np" and node[@rel="mod" and @cat="pp" and node[@rel="hd" and @pt="vz" and number(@begin) < number(../node[@rel="obj1" and @cat="np"]/node[@rel="mod" and @cat="pp"]/node[@rel="hd" and @pt="vz"]/@begin)] and node[@rel="obj1" and @cat="np" and node[@rel="mod" and @cat="pp" and node[@rel="hd" and @pt="vz"]]]]]] Admittedly, it's quite a long string, but I don't see anything wrong with it and I don't think the error lies in the XPath. The full trace is like follows: [XPTY0004] Item expected, sequence found: (attribute begin {"6"}, ...). at C:\xampp\htdocs\grinding\BaseXClient.pm line 213. at C:\xampp\htdocs\grinding\BaseXClient.pm line 213. Query::exc("\x{5}", 133) called at C:\xampp\htdocs\grinding\BaseXClient.pm line 177 Query::execute(Query=HASH(0x3adac40)) called at SonarBenchNew.pl line 249
        main::query_sonar("for \$node in
db:open(\"WRPEE0000000treebank\")/treebank//node[\@"...) called at
SonarBenchNew.pl line 176
main::loop_databases(ARRAY(0x31a2ae0), "//node[\@cat=\"pp\" and node[\@rel=\"hd\" and \@pt=\"vz\" and number(\@"...) called at SonarBenchNew.pl line 140 main::regular_sonar("//node[\@cat=\"pp\" and node[\@rel=\"hd\" and \@pt=\"vz\" and number(\@"...) called at SonarBenchNew.pl line 110 I have found that the XPTY0004 error is often caused by an order-by clause in XQuery but I don't have that. The full XQuery for the XPath is as follows: for $node in db:open("WRPEE0000000treebank")/treebank//node[@cat="pp" and node[@rel="hd" and @pt="vz" and number(@begin) < number(../node[@rel="obj1" and @cat="np"]/node[@rel="mod" and @cat="pp"]/node[@rel="hd" and @pt="vz"]/@begin)] and node[@rel="obj1" and @cat="np" and node[@rel="mod" and @cat="pp" and node[@rel="hd" and @pt="vz" and number(@begin) < number(../node[@rel="obj1" and @cat="np"]/node[@rel="mod" and @cat="pp"]/node[@rel="hd" and @pt="vz"]/@begin)] and node[@rel="obj1" and @cat="np" and node[@rel="mod" and @cat="pp" and node[@rel="hd" and @pt="vz"]]]]]]let $sentid := ($node/ancestor::alpino_ds/@id)let $sentence := ($node/ancestor::alpino_ds/sentence)let $tb := \'WRPEE0000000treebank\' return <match>{data($sentid)}||{data($sentence)}||{data($tb)}</match> I don't know if you guys can give me directions solely based on this. But if you could point me to a likely cause, e.g. input OR database contents, that would be great. Thanks in advance! Bram Vanroy https://bramvanroy.be
FE
Fabrice ETANCHAUD3 Mar 2017 12:33 #
Hi Bram From what one can read there : http://docs.basex.org/wiki/XQuery_Errors It seems to me that number() function could be called with a sequence of @begin. There might be a place in your query where multiple node elements are returned, leading to a node/@begin sequence. Best regards, Fabrice
Quoted text · Bram Vanroy · 22 lines
De : basex-talk-bounces at mailman.uni-konstanz.de [mailto:basex-talk-bounces at mailman.uni-konstanz.de] De la part de Bram Vanroy Envoyé : vendredi 3 mars 2017 12:19 À : 'BaseX' <basex-talk at mailman.uni-konstanz.de> Objet : [basex-talk] [XPTY0004] Item expected, sequence found Hi BaseX peeps I'm running BaseX 8.6.1 on Windows, and I'm running into an issue I can't explain. I am using BaseX to run some benchmarks. As a benchmark I am running different XPath structures to match on the same database. In other words, in a file of a hundred lines each line is an XPath structure, and with Perl I query each line and measure the time it takes. Simple enough, right? The strange thing is that my script runs fine but it crashes on line 17, which is this XPath code: //node[@cat="pp" and node[@rel="hd" and @pt="vz" and number(@begin) < number(../node[@rel="obj1" and @cat="np"]/node[@rel="mod" and @cat="pp"]/node[@rel="hd" and @pt="vz"]/@begin)] and node[@rel="obj1" and @cat="np" and node[@rel="mod" and @cat="pp" and node[@rel="hd" and @pt="vz" and number(@begin) < number(../node[@rel="obj1" and @cat="np"]/node[@rel="mod" and @cat="pp"]/node[@rel="hd" and @pt="vz"]/@begin)] and node[@rel="obj1" and @cat="np" and node[@rel="mod" and @cat="pp" and node[@rel="hd" and @pt="vz"]]]]]] Admittedly, it's quite a long string, but I don't see anything wrong with it and I don't think the error lies in the XPath. The full trace is like follows: [XPTY0004] Item expected, sequence found: (attribute begin {"6"}, ...). at C:\xampp\htdocs\grinding\BaseXClient.pm line 213. at C:\xampp\htdocs\grinding\BaseXClient.pm line 213. Query::exc("\x{5}", 133) called at C:\xampp\htdocs\grinding\BaseXClient.pm line 177 Query::execute(Query=HASH(0x3adac40)) called at SonarBenchNew.pl line 249 main::query_sonar("for \$node in db:open(\"WRPEE0000000treebank\")/treebank//node[\@"...) called at SonarBenchNew.pl line 176 main::loop_databases(ARRAY(0x31a2ae0), "//node[\@cat=\"pp\" and node[\@rel=\"hd\" and \@pt=\"vz\" and number(\@"...) called at SonarBenchNew.pl line 140 main::regular_sonar("//node[\@cat=\"pp\" and node[\@rel=\"hd\" and \@pt=\"vz\" and number(\@"...) called at SonarBenchNew.pl line 110 I have found that the XPTY0004 error is often caused by an order-by clause in XQuery but I don't have that. The full XQuery for the XPath is as follows: for $node in db:open("WRPEE0000000treebank")/treebank//node[@cat="pp" and node[@rel="hd" and @pt="vz" and number(@begin) < number(../node[@rel="obj1" and @cat="np"]/node[@rel="mod" and @cat="pp"]/node[@rel="hd" and @pt="vz"]/@begin)] and node[@rel="obj1" and @cat="np" and node[@rel="mod" and @cat="pp" and node[@rel="hd" and @pt="vz" and number(@begin) < number(../node[@rel="obj1" and @cat="np"]/node[@rel="mod" and @cat="pp"]/node[@rel="hd" and @pt="vz"]/@begin)] and node[@rel="obj1" and @cat="np" and node[@rel="mod" and @cat="pp" and node[@rel="hd" and @pt="vz"]]]]]]let $sentid := ($node/ancestor::alpino_ds/@id)let $sentence := ($node/ancestor::alpino_ds/sentence)let $tb := \'WRPEE0000000treebank\' return <match>{data($sentid)}||{data($sentence)}||{data($tb)}</match> I don't know if you guys can give me directions solely based on this. But if you could point me to a likely cause, e.g. input OR database contents, that would be great. Thanks in advance! Bram Vanroy https://bramvanroy.be
BV
Bram Vanroy3 Mar 2017 12:52 #
Hi Fabrice thank you for the quick reply. Unfortunately I do not understand what you mean. I have queried other XPath codes with the number() function and the begin attribute without fault. However, it does seem to point in that direction as the error explicitly mentions that attribute: attribute begin {"6"}, Because other lines in the benchmark with the number() function and begin attribute do not throw this error, I do not know where to look.
Quoted text · Fabrice ETANCHAUD · 77 lines
Van: Fabrice ETANCHAUD [mailto:fetanchaud at groupefbo.com] Verzonden: vrijdag 3 maart 2017 12:33 Aan: Bram Vanroy <bram.vanroy1 at student.kuleuven.be>; 'BaseX' <basex-talk at mailman.uni-konstanz.de> Onderwerp: RE: [basex-talk] [XPTY0004] Item expected, sequence found Hi Bram From what one can read there : http://docs.basex.org/wiki/XQuery_Errors It seems to me that number() function could be called with a sequence of @begin. There might be a place in your query where multiple node elements are returned, leading to a node/@begin sequence. Best regards, Fabrice De : basex-talk-bounces at mailman.uni-konstanz.de <mailto:basex-talk-bounces at mailman.uni-konstanz.de> [mailto:basex-talk-bounces at mailman.uni-konstanz.de] De la part de Bram Vanroy Envoyé : vendredi 3 mars 2017 12:19 À : 'BaseX' <basex-talk at mailman.uni-konstanz.de <mailto:basex-talk at mailman.uni-konstanz.de> > Objet : [basex-talk] [XPTY0004] Item expected, sequence found Hi BaseX peeps Im running BaseX 8.6.1 on Windows, and Im running into an issue I cant explain. I am using BaseX to run some benchmarks. As a benchmark I am running different XPath structures to match on the same database. In other words, in a file of a hundred lines each line is an XPath structure, and with Perl I query each line and measure the time it takes. Simple enough, right? The strange thing is that my script runs fine but it crashes on line 17, which is this XPath code: //node[@cat="pp" and node[@rel="hd" and @pt="vz" and number(@begin) < number(../node[@rel="obj1" and @cat="np"]/node[@rel="mod" and @cat="pp"]/node[@rel="hd" and @pt="vz"]/@begin)] and node[@rel="obj1" and @cat="np" and node[@rel="mod" and @cat="pp" and node[@rel="hd" and @pt="vz" and number(@begin) < number(../node[@rel="obj1" and @cat="np"]/node[@rel="mod" and @cat="pp"]/node[@rel="hd" and @pt="vz"]/@begin)] and node[@rel="obj1" and @cat="np" and node[@rel="mod" and @cat="pp" and node[@rel="hd" and @pt="vz"]]]]]] Admittedly, its quite a long string, but I dont see anything wrong with it and I dont think the error lies in the XPath. The full trace is like follows: [XPTY0004] Item expected, sequence found: (attribute begin {"6"}, ...). at C:\xampp\htdocs\grinding\BaseXClient.pm line 213. at C:\xampp\htdocs\grinding\BaseXClient.pm line 213. Query::exc("\x{5}", 133) called at C:\xampp\htdocs\grinding\BaseXClient.pm line 177 Query::execute(Query=HASH(0x3adac40)) called at SonarBenchNew.pl line 249 main::query_sonar("for \$node in db:open(\"WRPEE0000000treebank\")/treebank//node[\@"...) called at SonarBenchNew.pl line 176 main::loop_databases(ARRAY(0x31a2ae0), "//node[\@cat=\"pp\" and node[\@rel=\"hd\" and \@pt=\"vz\" and number(\@"...) called at SonarBenchNew.pl line 140 main::regular_sonar("//node[\@cat=\"pp\" and node[\@rel=\"hd\" and \@pt=\"vz\" and number(\@"...) called at SonarBenchNew.pl line 110 I have found that the XPTY0004 error is often caused by an order-by clause in XQuery but I dont have that. The full XQuery for the XPath is as follows: for $node in db:open("WRPEE0000000treebank")/treebank//node[@cat="pp" and node[@rel="hd" and @pt="vz" and number(@begin) < number(../node[@rel="obj1" and @cat="np"]/node[@rel="mod" and @cat="pp"]/node[@rel="hd" and @pt="vz"]/@begin)] and node[@rel="obj1" and @cat="np" and node[@rel="mod" and @cat="pp" and node[@rel="hd" and @pt="vz" and number(@begin) < number(../node[@rel="obj1" and @cat="np"]/node[@rel="mod" and @cat="pp"]/node[@rel="hd" and @pt="vz"]/@begin)] and node[@rel="obj1" and @cat="np" and node[@rel="mod" and @cat="pp" and node[@rel="hd" and @pt="vz"]]]]]]let $sentid := ($node/ancestor::alpino_ds/@id)let $sentence := ($node/ancestor::alpino_ds/sentence)let $tb := \'WRPEE0000000treebank\' return <match>{data($sentid)}||{data($sentence)}||{data($tb)}</match> I dont know if you guys can give me directions solely based on this. But if you could point me to a likely cause, e.g. input OR database contents, that would be great. Thanks in advance! Bram Vanroy https://bramvanroy.be
FE
Fabrice ETANCHAUD3 Mar 2017 16:30 #
Hello Bram, Sorry I mean it might not be xquery related, but xml related (in your dataset). Maybe running a modified version of your script twice, Replacing separately each bold statement below with and count(../node[ @rel="obj1" and @cat="np" ]/node[ @rel="mod" and @cat="pp" ]/node[ @rel="hd" and @pt="vz" ]/@begin) > 1 Will help you identify where you have more than one matching element ? Best regards, Fabrice //node[ @cat="pp" and node[ @rel="hd" and @pt="vz" and number(@begin) < number( ../node[ @rel="obj1" and @cat="np" ]/node[ @rel="mod" and @cat="pp" ]/node[ @rel="hd" and @pt="vz" ]/@begin) ] and node[ @rel="obj1" and @cat="np" and node[ @rel="mod" and @cat="pp" and node[ @rel="hd" and @pt="vz" and number(@begin) < number( ../node[ @rel="obj1" and @cat="np" ]/node[ @rel="mod" and @cat="pp" ]/node[ @rel="hd" and @pt="vz" ]/@begin) ] and node[ @rel="obj1" and @cat="np" and node[ @rel="mod" and @cat="pp" and node[ @rel="hd" and @pt="vz" ] ] ] ] ] ]
Quoted text · Bram Vanroy · 41 lines
De : Bram Vanroy [mailto:bram.vanroy1 at student.kuleuven.be] Envoyé : vendredi 3 mars 2017 12:52 À : Fabrice ETANCHAUD <fetanchaud at groupefbo.com>; 'BaseX' <basex-talk at mailman.uni-konstanz.de> Objet : RE: [basex-talk] [XPTY0004] Item expected, sequence found Hi Fabrice thank you for the quick reply. Unfortunately I do not understand what you mean. I have queried other XPath codes with the number() function and the begin attribute without fault. However, it does seem to point in that direction as the error explicitly mentions that attribute: attribute begin {"6"}, Because other lines in the benchmark with the number() function and begin attribute do not throw this error, I do not know where to look. Van: Fabrice ETANCHAUD [mailto:fetanchaud at groupefbo.com] Verzonden: vrijdag 3 maart 2017 12:33 Aan: Bram Vanroy <bram.vanroy1 at student.kuleuven.be<mailto:bram.vanroy1 at student.kuleuven.be>>; 'BaseX' <basex-talk at mailman.uni-konstanz.de<mailto:basex-talk at mailman.uni-konstanz.de>> Onderwerp: RE: [basex-talk] [XPTY0004] Item expected, sequence found Hi Bram From what one can read there : http://docs.basex.org/wiki/XQuery_Errors It seems to me that number() function could be called with a sequence of @begin. There might be a place in your query where multiple node elements are returned, leading to a node/@begin sequence. Best regards, Fabrice De : basex-talk-bounces at mailman.uni-konstanz.de<mailto:basex-talk-bounces at mailman.uni-konstanz.de> [mailto:basex-talk-bounces at mailman.uni-konstanz.de] De la part de Bram Vanroy Envoyé : vendredi 3 mars 2017 12:19 À : 'BaseX' <basex-talk at mailman.uni-konstanz.de<mailto:basex-talk at mailman.uni-konstanz.de>> Objet : [basex-talk] [XPTY0004] Item expected, sequence found Hi BaseX peeps I'm running BaseX 8.6.1 on Windows, and I'm running into an issue I can't explain. I am using BaseX to run some benchmarks. As a benchmark I am running different XPath structures to match on the same database. In other words, in a file of a hundred lines each line is an XPath structure, and with Perl I query each line and measure the time it takes. Simple enough, right? The strange thing is that my script runs fine but it crashes on line 17, which is this XPath code: //node[@cat="pp" and node[@rel="hd" and @pt="vz" and number(@begin) < number(../node[@rel="obj1" and @cat="np"]/node[@rel="mod" and @cat="pp"]/node[@rel="hd" and @pt="vz"]/@begin)] and node[@rel="obj1" and @cat="np" and node[@rel="mod" and @cat="pp" and node[@rel="hd" and @pt="vz" and number(@begin) < number(../node[@rel="obj1" and @cat="np"]/node[@rel="mod" and @cat="pp"]/node[@rel="hd" and @pt="vz"]/@begin)] and node[@rel="obj1" and @cat="np" and node[@rel="mod" and @cat="pp" and node[@rel="hd" and @pt="vz"]]]]]] Admittedly, it's quite a long string, but I don't see anything wrong with it and I don't think the error lies in the XPath. The full trace is like follows: [XPTY0004] Item expected, sequence found: (attribute begin {"6"}, ...). at C:\xampp\htdocs\grinding\BaseXClient.pm line 213. at C:\xampp\htdocs\grinding\BaseXClient.pm line 213. Query::exc("\x{5}", 133) called at C:\xampp\htdocs\grinding\BaseXClient.pm line 177 Query::execute(Query=HASH(0x3adac40)) called at SonarBenchNew.pl line 249 main::query_sonar("for \$node in db:open(\"WRPEE0000000treebank\")/treebank//node[\@"...) called at SonarBenchNew.pl line 176 main::loop_databases(ARRAY(0x31a2ae0), "//node[\@cat=\"pp\" and node[\@rel=\"hd\" and \@pt=\"vz\" and number(\@"...) called at SonarBenchNew.pl line 140 main::regular_sonar("//node[\@cat=\"pp\" and node[\@rel=\"hd\" and \@pt=\"vz\" and number(\@"...) called at SonarBenchNew.pl line 110 I have found that the XPTY0004 error is often caused by an order-by clause in XQuery but I don't have that. The full XQuery for the XPath is as follows: for $node in db:open("WRPEE0000000treebank")/treebank//node[@cat="pp" and node[@rel="hd" and @pt="vz" and number(@begin) < number(../node[@rel="obj1" and @cat="np"]/node[@rel="mod" and @cat="pp"]/node[@rel="hd" and @pt="vz"]/@begin)] and node[@rel="obj1" and @cat="np" and node[@rel="mod" and @cat="pp" and node[@rel="hd" and @pt="vz" and number(@begin) < number(../node[@rel="obj1" and @cat="np"]/node[@rel="mod" and @cat="pp"]/node[@rel="hd" and @pt="vz"]/@begin)] and node[@rel="obj1" and @cat="np" and node[@rel="mod" and @cat="pp" and node[@rel="hd" and @pt="vz"]]]]]]let $sentid := ($node/ancestor::alpino_ds/@id)let $sentence := ($node/ancestor::alpino_ds/sentence)let $tb := \'WRPEE0000000treebank\' return <match>{data($sentid)}||{data($sentence)}||{data($tb)}</match> I don't know if you guys can give me directions solely based on this. But if you could point me to a likely cause, e.g. input OR database contents, that would be great. Thanks in advance! Bram Vanroy https://bramvanroy.be
BV
Bram Vanroy3 Mar 2017 19:38 #
Good evening Fabrice I have tried what you suggested, and indeed: when I replace the first block the script works fine, and when I replace the second it does not. But Im not sure what this means, or how I can solve this in XPath? (Im sorry, I really am not good with XPath and XQuery.) I dont know if this is relevant, but when I try the query with one slash in the front instead of two, the script works fine as well. Thank you for the help so far!
Quoted text · Fabrice ETANCHAUD · 164 lines
Van: Fabrice ETANCHAUD [mailto:fetanchaud at groupefbo.com] Verzonden: vrijdag 3 maart 2017 16:30 Aan: Bram Vanroy <bram.vanroy1 at student.kuleuven.be>; 'BaseX' <basex-talk at mailman.uni-konstanz.de> Onderwerp: RE: [basex-talk] [XPTY0004] Item expected, sequence found Hello Bram, Sorry I mean it might not be xquery related, but xml related (in your dataset). Maybe running a modified version of your script twice, Replacing separately each bold statement below with and count(../node[ @rel="obj1" and @cat="np" ]/node[ @rel="mod" and @cat="pp" ]/node[ @rel="hd" and @pt="vz" ]/@begin) > 1 Will help you identify where you have more than one matching element ? Best regards, Fabrice //node[ @cat="pp" and node[ @rel="hd" and @pt="vz" and number(@begin) < number( ../node[ @rel="obj1" and @cat="np" ]/node[ @rel="mod" and @cat="pp" ]/node[ @rel="hd" and @pt="vz" ]/@begin) ] and node[ @rel="obj1" and @cat="np" and node[ @rel="mod" and @cat="pp" and node[ @rel="hd" and @pt="vz" and number(@begin) < number( ../node[ @rel="obj1" and @cat="np" ]/node[ @rel="mod" and @cat="pp" ]/node[ @rel="hd" and @pt="vz" ]/@begin) ] and node[ @rel="obj1" and @cat="np" and node[ @rel="mod" and @cat="pp" and node[ @rel="hd" and @pt="vz" ] ] ] ] ] ] De : Bram Vanroy [mailto:bram.vanroy1 at student.kuleuven.be] Envoyé : vendredi 3 mars 2017 12:52 À : Fabrice ETANCHAUD <fetanchaud at groupefbo.com <mailto:fetanchaud at groupefbo.com> >; 'BaseX' <basex-talk at mailman.uni-konstanz.de <mailto:basex-talk at mailman.uni-konstanz.de> > Objet : RE: [basex-talk] [XPTY0004] Item expected, sequence found Hi Fabrice thank you for the quick reply. Unfortunately I do not understand what you mean. I have queried other XPath codes with the number() function and the begin attribute without fault. However, it does seem to point in that direction as the error explicitly mentions that attribute: attribute begin {"6"}, Because other lines in the benchmark with the number() function and begin attribute do not throw this error, I do not know where to look. Van: Fabrice ETANCHAUD [mailto:fetanchaud at groupefbo.com] Verzonden: vrijdag 3 maart 2017 12:33 Aan: Bram Vanroy <bram.vanroy1 at student.kuleuven.be <mailto:bram.vanroy1 at student.kuleuven.be> >; 'BaseX' <basex-talk at mailman.uni-konstanz.de <mailto:basex-talk at mailman.uni-konstanz.de> > Onderwerp: RE: [basex-talk] [XPTY0004] Item expected, sequence found Hi Bram From what one can read there : http://docs.basex.org/wiki/XQuery_Errors It seems to me that number() function could be called with a sequence of @begin. There might be a place in your query where multiple node elements are returned, leading to a node/@begin sequence. Best regards, Fabrice De : basex-talk-bounces at mailman.uni-konstanz.de <mailto:basex-talk-bounces at mailman.uni-konstanz.de> [mailto:basex-talk-bounces at mailman.uni-konstanz.de] De la part de Bram Vanroy Envoyé : vendredi 3 mars 2017 12:19 À : 'BaseX' <basex-talk at mailman.uni-konstanz.de <mailto:basex-talk at mailman.uni-konstanz.de> > Objet : [basex-talk] [XPTY0004] Item expected, sequence found Hi BaseX peeps Im running BaseX 8.6.1 on Windows, and Im running into an issue I cant explain. I am using BaseX to run some benchmarks. As a benchmark I am running different XPath structures to match on the same database. In other words, in a file of a hundred lines each line is an XPath structure, and with Perl I query each line and measure the time it takes. Simple enough, right? The strange thing is that my script runs fine but it crashes on line 17, which is this XPath code: //node[@cat="pp" and node[@rel="hd" and @pt="vz" and number(@begin) < number(../node[@rel="obj1" and @cat="np"]/node[@rel="mod" and @cat="pp"]/node[@rel="hd" and @pt="vz"]/@begin)] and node[@rel="obj1" and @cat="np" and node[@rel="mod" and @cat="pp" and node[@rel="hd" and @pt="vz" and number(@begin) < number(../node[@rel="obj1" and @cat="np"]/node[@rel="mod" and @cat="pp"]/node[@rel="hd" and @pt="vz"]/@begin)] and node[@rel="obj1" and @cat="np" and node[@rel="mod" and @cat="pp" and node[@rel="hd" and @pt="vz"]]]]]] Admittedly, its quite a long string, but I dont see anything wrong with it and I dont think the error lies in the XPath. The full trace is like follows: [XPTY0004] Item expected, sequence found: (attribute begin {"6"}, ...). at C:\xampp\htdocs\grinding\BaseXClient.pm line 213. at C:\xampp\htdocs\grinding\BaseXClient.pm line 213. Query::exc("\x{5}", 133) called at C:\xampp\htdocs\grinding\BaseXClient.pm line 177 Query::execute(Query=HASH(0x3adac40)) called at SonarBenchNew.pl line 249 main::query_sonar("for \$node in db:open(\"WRPEE0000000treebank\")/treebank//node[\@"...) called at SonarBenchNew.pl line 176 main::loop_databases(ARRAY(0x31a2ae0), "//node[\@cat=\"pp\" and node[\@rel=\"hd\" and \@pt=\"vz\" and number(\@"...) called at SonarBenchNew.pl line 140 main::regular_sonar("//node[\@cat=\"pp\" and node[\@rel=\"hd\" and \@pt=\"vz\" and number(\@"...) called at SonarBenchNew.pl line 110 I have found that the XPTY0004 error is often caused by an order-by clause in XQuery but I dont have that. The full XQuery for the XPath is as follows: for $node in db:open("WRPEE0000000treebank")/treebank//node[@cat="pp" and node[@rel="hd" and @pt="vz" and number(@begin) < number(../node[@rel="obj1" and @cat="np"]/node[@rel="mod" and @cat="pp"]/node[@rel="hd" and @pt="vz"]/@begin)] and node[@rel="obj1" and @cat="np" and node[@rel="mod" and @cat="pp" and node[@rel="hd" and @pt="vz" and number(@begin) < number(../node[@rel="obj1" and @cat="np"]/node[@rel="mod" and @cat="pp"]/node[@rel="hd" and @pt="vz"]/@begin)] and node[@rel="obj1" and @cat="np" and node[@rel="mod" and @cat="pp" and node[@rel="hd" and @pt="vz"]]]]]]let $sentid := ($node/ancestor::alpino_ds/@id)let $sentence := ($node/ancestor::alpino_ds/sentence)let $tb := \'WRPEE0000000treebank\' return <match>{data($sentid)}||{data($sentence)}||{data($tb)}</match> I dont know if you guys can give me directions solely based on this. But if you could point me to a likely cause, e.g. input OR database contents, that would be great. Thanks in advance! Bram Vanroy https://bramvanroy.be
FE
Fabrice ETANCHAUD6 Mar 2017 09:14 #
Hello Bram, Sorry for the delay, It means there is more than one node element matching : ../node[ @rel="obj1" and @cat="np" ]/node[ @rel="mod" and @cat="pp" ]/node[ @rel="hd" and @pt="vz" ]/ You could make you request work by taking for example only the first @begin attribute : and number(@begin) < number( ( ../node[ @rel="obj1" and @cat="np" ]/node[ @rel="mod" and @cat="pp" ]/node[ @rel="hd" and @pt="vz" ]/@begin)[1]) ] But it may be meaningless with respect to your data. Hoping it will help, Best regards, Fabrice
Quoted text · Bram Vanroy · 117 lines
De : Bram Vanroy [mailto:bram.vanroy1 at student.kuleuven.be] Envoyé : vendredi 3 mars 2017 19:39 À : Fabrice ETANCHAUD <fetanchaud at groupefbo.com>; 'BaseX' <basex-talk at mailman.uni-konstanz.de> Objet : RE: [basex-talk] [XPTY0004] Item expected, sequence found Good evening Fabrice I have tried what you suggested, and indeed: when I replace the first block the script works fine, and when I replace the second it does not. But I'm not sure what this means, or how I can solve this in XPath? (I'm sorry, I really am not good with XPath and XQuery.) I don't know if this is relevant, but when I try the query with one slash in the front instead of two, the script works fine as well. Thank you for the help so far! Van: Fabrice ETANCHAUD [mailto:fetanchaud at groupefbo.com] Verzonden: vrijdag 3 maart 2017 16:30 Aan: Bram Vanroy <bram.vanroy1 at student.kuleuven.be<mailto:bram.vanroy1 at student.kuleuven.be>>; 'BaseX' <basex-talk at mailman.uni-konstanz.de<mailto:basex-talk at mailman.uni-konstanz.de>> Onderwerp: RE: [basex-talk] [XPTY0004] Item expected, sequence found Hello Bram, Sorry I mean it might not be xquery related, but xml related (in your dataset). Maybe running a modified version of your script twice, Replacing separately each bold statement below with and count(../node[ @rel="obj1" and @cat="np" ]/node[ @rel="mod" and @cat="pp" ]/node[ @rel="hd" and @pt="vz" ]/@begin) > 1 Will help you identify where you have more than one matching element ? Best regards, Fabrice //node[ @cat="pp" and node[ @rel="hd" and @pt="vz" and number(@begin) < number( ../node[ @rel="obj1" and @cat="np" ]/node[ @rel="mod" and @cat="pp" ]/node[ @rel="hd" and @pt="vz" ]/@begin) ] and node[ @rel="obj1" and @cat="np" and node[ @rel="mod" and @cat="pp" and node[ @rel="hd" and @pt="vz" and number(@begin) < number( ../node[ @rel="obj1" and @cat="np" ]/node[ @rel="mod" and @cat="pp" ]/node[ @rel="hd" and @pt="vz" ]/@begin) ] and node[ @rel="obj1" and @cat="np" and node[ @rel="mod" and @cat="pp" and node[ @rel="hd" and @pt="vz" ] ] ] ] ] ] De : Bram Vanroy [mailto:bram.vanroy1 at student.kuleuven.be] Envoyé : vendredi 3 mars 2017 12:52 À : Fabrice ETANCHAUD <fetanchaud at groupefbo.com<mailto:fetanchaud at groupefbo.com>>; 'BaseX' <basex-talk at mailman.uni-konstanz.de<mailto:basex-talk at mailman.uni-konstanz.de>> Objet : RE: [basex-talk] [XPTY0004] Item expected, sequence found Hi Fabrice thank you for the quick reply. Unfortunately I do not understand what you mean. I have queried other XPath codes with the number() function and the begin attribute without fault. However, it does seem to point in that direction as the error explicitly mentions that attribute: attribute begin {"6"}, Because other lines in the benchmark with the number() function and begin attribute do not throw this error, I do not know where to look. Van: Fabrice ETANCHAUD [mailto:fetanchaud at groupefbo.com] Verzonden: vrijdag 3 maart 2017 12:33 Aan: Bram Vanroy <bram.vanroy1 at student.kuleuven.be<mailto:bram.vanroy1 at student.kuleuven.be>>; 'BaseX' <basex-talk at mailman.uni-konstanz.de<mailto:basex-talk at mailman.uni-konstanz.de>> Onderwerp: RE: [basex-talk] [XPTY0004] Item expected, sequence found Hi Bram From what one can read there : http://docs.basex.org/wiki/XQuery_Errors It seems to me that number() function could be called with a sequence of @begin. There might be a place in your query where multiple node elements are returned, leading to a node/@begin sequence. Best regards, Fabrice De : basex-talk-bounces at mailman.uni-konstanz.de<mailto:basex-talk-bounces at mailman.uni-konstanz.de> [mailto:basex-talk-bounces at mailman.uni-konstanz.de] De la part de Bram Vanroy Envoyé : vendredi 3 mars 2017 12:19 À : 'BaseX' <basex-talk at mailman.uni-konstanz.de<mailto:basex-talk at mailman.uni-konstanz.de>> Objet : [basex-talk] [XPTY0004] Item expected, sequence found Hi BaseX peeps I'm running BaseX 8.6.1 on Windows, and I'm running into an issue I can't explain. I am using BaseX to run some benchmarks. As a benchmark I am running different XPath structures to match on the same database. In other words, in a file of a hundred lines each line is an XPath structure, and with Perl I query each line and measure the time it takes. Simple enough, right? The strange thing is that my script runs fine but it crashes on line 17, which is this XPath code: //node[@cat="pp" and node[@rel="hd" and @pt="vz" and number(@begin) < number(../node[@rel="obj1" and @cat="np"]/node[@rel="mod" and @cat="pp"]/node[@rel="hd" and @pt="vz"]/@begin)] and node[@rel="obj1" and @cat="np" and node[@rel="mod" and @cat="pp" and node[@rel="hd" and @pt="vz" and number(@begin) < number(../node[@rel="obj1" and @cat="np"]/node[@rel="mod" and @cat="pp"]/node[@rel="hd" and @pt="vz"]/@begin)] and node[@rel="obj1" and @cat="np" and node[@rel="mod" and @cat="pp" and node[@rel="hd" and @pt="vz"]]]]]] Admittedly, it's quite a long string, but I don't see anything wrong with it and I don't think the error lies in the XPath. The full trace is like follows: [XPTY0004] Item expected, sequence found: (attribute begin {"6"}, ...). at C:\xampp\htdocs\grinding\BaseXClient.pm line 213. at C:\xampp\htdocs\grinding\BaseXClient.pm line 213. Query::exc("\x{5}", 133) called at C:\xampp\htdocs\grinding\BaseXClient.pm line 177 Query::execute(Query=HASH(0x3adac40)) called at SonarBenchNew.pl line 249 main::query_sonar("for \$node in db:open(\"WRPEE0000000treebank\")/treebank//node[\@"...) called at SonarBenchNew.pl line 176 main::loop_databases(ARRAY(0x31a2ae0), "//node[\@cat=\"pp\" and node[\@rel=\"hd\" and \@pt=\"vz\" and number(\@"...) called at SonarBenchNew.pl line 140 main::regular_sonar("//node[\@cat=\"pp\" and node[\@rel=\"hd\" and \@pt=\"vz\" and number(\@"...) called at SonarBenchNew.pl line 110 I have found that the XPTY0004 error is often caused by an order-by clause in XQuery but I don't have that. The full XQuery for the XPath is as follows: for $node in db:open("WRPEE0000000treebank")/treebank//node[@cat="pp" and node[@rel="hd" and @pt="vz" and number(@begin) < number(../node[@rel="obj1" and @cat="np"]/node[@rel="mod" and @cat="pp"]/node[@rel="hd" and @pt="vz"]/@begin)] and node[@rel="obj1" and @cat="np" and node[@rel="mod" and @cat="pp" and node[@rel="hd" and @pt="vz" and number(@begin) < number(../node[@rel="obj1" and @cat="np"]/node[@rel="mod" and @cat="pp"]/node[@rel="hd" and @pt="vz"]/@begin)] and node[@rel="obj1" and @cat="np" and node[@rel="mod" and @cat="pp" and node[@rel="hd" and @pt="vz"]]]]]]let $sentid := ($node/ancestor::alpino_ds/@id)let $sentence := ($node/ancestor::alpino_ds/sentence)let $tb := \'WRPEE0000000treebank\' return <match>{data($sentid)}||{data($sentence)}||{data($tb)}</match> I don't know if you guys can give me directions solely based on this. But if you could point me to a likely cause, e.g. input OR database contents, that would be great. Thanks in advance! Bram Vanroy https://bramvanroy.be
BV
Bram Vanroy8 Mar 2017 14:57 #
Hi Fabrice and others I have been breaking my head over this the last few days and cant get it right. I tried your suggestion, but that does not work either. I have made the data available for testing and added a question on Stack Overflow. Anyone, feel free to help me out! [1] Thanks in advance! [1] http://stackoverflow.com/q/42673237/1150683
Quoted text · Fabrice ETANCHAUD · 211 lines
Van: Fabrice ETANCHAUD [mailto:fetanchaud at groupefbo.com] Verzonden: maandag 6 maart 2017 9:14 Aan: Bram Vanroy <bram.vanroy1 at student.kuleuven.be>; 'BaseX' <basex-talk at mailman.uni-konstanz.de> Onderwerp: RE: [basex-talk] [XPTY0004] Item expected, sequence found Hello Bram, Sorry for the delay, It means there is more than one node element matching : ../node[ @rel="obj1" and @cat="np" ]/node[ @rel="mod" and @cat="pp" ]/node[ @rel="hd" and @pt="vz" ]/ You could make you request work by taking for example only the first @begin attribute : and number(@begin) < number( ( ../node[ @rel="obj1" and @cat="np" ]/node[ @rel="mod" and @cat="pp" ]/node[ @rel="hd" and @pt="vz" ]/@begin)[1]) ] But it may be meaningless with respect to your data. Hoping it will help, Best regards, Fabrice De : Bram Vanroy [mailto:bram.vanroy1 at student.kuleuven.be] Envoyé : vendredi 3 mars 2017 19:39 À : Fabrice ETANCHAUD <fetanchaud at groupefbo.com <mailto:fetanchaud at groupefbo.com> >; 'BaseX' <basex-talk at mailman.uni-konstanz.de <mailto:basex-talk at mailman.uni-konstanz.de> > Objet : RE: [basex-talk] [XPTY0004] Item expected, sequence found Good evening Fabrice I have tried what you suggested, and indeed: when I replace the first block the script works fine, and when I replace the second it does not. But Im not sure what this means, or how I can solve this in XPath? (Im sorry, I really am not good with XPath and XQuery.) I dont know if this is relevant, but when I try the query with one slash in the front instead of two, the script works fine as well. Thank you for the help so far! Van: Fabrice ETANCHAUD [mailto:fetanchaud at groupefbo.com] Verzonden: vrijdag 3 maart 2017 16:30 Aan: Bram Vanroy <bram.vanroy1 at student.kuleuven.be <mailto:bram.vanroy1 at student.kuleuven.be> >; 'BaseX' <basex-talk at mailman.uni-konstanz.de <mailto:basex-talk at mailman.uni-konstanz.de> > Onderwerp: RE: [basex-talk] [XPTY0004] Item expected, sequence found Hello Bram, Sorry I mean it might not be xquery related, but xml related (in your dataset). Maybe running a modified version of your script twice, Replacing separately each bold statement below with and count(../node[ @rel="obj1" and @cat="np" ]/node[ @rel="mod" and @cat="pp" ]/node[ @rel="hd" and @pt="vz" ]/@begin) > 1 Will help you identify where you have more than one matching element ? Best regards, Fabrice //node[ @cat="pp" and node[ @rel="hd" and @pt="vz" and number(@begin) < number( ../node[ @rel="obj1" and @cat="np" ]/node[ @rel="mod" and @cat="pp" ]/node[ @rel="hd" and @pt="vz" ]/@begin) ] and node[ @rel="obj1" and @cat="np" and node[ @rel="mod" and @cat="pp" and node[ @rel="hd" and @pt="vz" and number(@begin) < number( ../node[ @rel="obj1" and @cat="np" ]/node[ @rel="mod" and @cat="pp" ]/node[ @rel="hd" and @pt="vz" ]/@begin) ] and node[ @rel="obj1" and @cat="np" and node[ @rel="mod" and @cat="pp" and node[ @rel="hd" and @pt="vz" ] ] ] ] ] ] De : Bram Vanroy [mailto:bram.vanroy1 at student.kuleuven.be] Envoyé : vendredi 3 mars 2017 12:52 À : Fabrice ETANCHAUD <fetanchaud at groupefbo.com <mailto:fetanchaud at groupefbo.com> >; 'BaseX' <basex-talk at mailman.uni-konstanz.de <mailto:basex-talk at mailman.uni-konstanz.de> > Objet : RE: [basex-talk] [XPTY0004] Item expected, sequence found Hi Fabrice thank you for the quick reply. Unfortunately I do not understand what you mean. I have queried other XPath codes with the number() function and the begin attribute without fault. However, it does seem to point in that direction as the error explicitly mentions that attribute: attribute begin {"6"}, Because other lines in the benchmark with the number() function and begin attribute do not throw this error, I do not know where to look. Van: Fabrice ETANCHAUD [mailto:fetanchaud at groupefbo.com] Verzonden: vrijdag 3 maart 2017 12:33 Aan: Bram Vanroy <bram.vanroy1 at student.kuleuven.be <mailto:bram.vanroy1 at student.kuleuven.be> >; 'BaseX' <basex-talk at mailman.uni-konstanz.de <mailto:basex-talk at mailman.uni-konstanz.de> > Onderwerp: RE: [basex-talk] [XPTY0004] Item expected, sequence found Hi Bram From what one can read there : http://docs.basex.org/wiki/XQuery_Errors It seems to me that number() function could be called with a sequence of @begin. There might be a place in your query where multiple node elements are returned, leading to a node/@begin sequence. Best regards, Fabrice De : basex-talk-bounces at mailman.uni-konstanz.de <mailto:basex-talk-bounces at mailman.uni-konstanz.de> [mailto:basex-talk-bounces at mailman.uni-konstanz.de] De la part de Bram Vanroy Envoyé : vendredi 3 mars 2017 12:19 À : 'BaseX' <basex-talk at mailman.uni-konstanz.de <mailto:basex-talk at mailman.uni-konstanz.de> > Objet : [basex-talk] [XPTY0004] Item expected, sequence found Hi BaseX peeps Im running BaseX 8.6.1 on Windows, and Im running into an issue I cant explain. I am using BaseX to run some benchmarks. As a benchmark I am running different XPath structures to match on the same database. In other words, in a file of a hundred lines each line is an XPath structure, and with Perl I query each line and measure the time it takes. Simple enough, right? The strange thing is that my script runs fine but it crashes on line 17, which is this XPath code: //node[@cat="pp" and node[@rel="hd" and @pt="vz" and number(@begin) < number(../node[@rel="obj1" and @cat="np"]/node[@rel="mod" and @cat="pp"]/node[@rel="hd" and @pt="vz"]/@begin)] and node[@rel="obj1" and @cat="np" and node[@rel="mod" and @cat="pp" and node[@rel="hd" and @pt="vz" and number(@begin) < number(../node[@rel="obj1" and @cat="np"]/node[@rel="mod" and @cat="pp"]/node[@rel="hd" and @pt="vz"]/@begin)] and node[@rel="obj1" and @cat="np" and node[@rel="mod" and @cat="pp" and node[@rel="hd" and @pt="vz"]]]]]] Admittedly, its quite a long string, but I dont see anything wrong with it and I dont think the error lies in the XPath. The full trace is like follows: [XPTY0004] Item expected, sequence found: (attribute begin {"6"}, ...). at C:\xampp\htdocs\grinding\BaseXClient.pm line 213. at C:\xampp\htdocs\grinding\BaseXClient.pm line 213. Query::exc("\x{5}", 133) called at C:\xampp\htdocs\grinding\BaseXClient.pm line 177 Query::execute(Query=HASH(0x3adac40)) called at SonarBenchNew.pl line 249 main::query_sonar("for \$node in db:open(\"WRPEE0000000treebank\")/treebank//node[\@"...) called at SonarBenchNew.pl line 176 main::loop_databases(ARRAY(0x31a2ae0), "//node[\@cat=\"pp\" and node[\@rel=\"hd\" and \@pt=\"vz\" and number(\@"...) called at SonarBenchNew.pl line 140 main::regular_sonar("//node[\@cat=\"pp\" and node[\@rel=\"hd\" and \@pt=\"vz\" and number(\@"...) called at SonarBenchNew.pl line 110 I have found that the XPTY0004 error is often caused by an order-by clause in XQuery but I dont have that. The full XQuery for the XPath is as follows: for $node in db:open("WRPEE0000000treebank")/treebank//node[@cat="pp" and node[@rel="hd" and @pt="vz" and number(@begin) < number(../node[@rel="obj1" and @cat="np"]/node[@rel="mod" and @cat="pp"]/node[@rel="hd" and @pt="vz"]/@begin)] and node[@rel="obj1" and @cat="np" and node[@rel="mod" and @cat="pp" and node[@rel="hd" and @pt="vz" and number(@begin) < number(../node[@rel="obj1" and @cat="np"]/node[@rel="mod" and @cat="pp"]/node[@rel="hd" and @pt="vz"]/@begin)] and node[@rel="obj1" and @cat="np" and node[@rel="mod" and @cat="pp" and node[@rel="hd" and @pt="vz"]]]]]]let $sentid := ($node/ancestor::alpino_ds/@id)let $sentence := ($node/ancestor::alpino_ds/sentence)let $tb := \'WRPEE0000000treebank\' return <match>{data($sentid)}||{data($sentence)}||{data($tb)}</match> I dont know if you guys can give me directions solely based on this. But if you could point me to a likely cause, e.g. input OR database contents, that would be great. Thanks in advance! Bram Vanroy https://bramvanroy.be
AB
Andy Bunce8 Mar 2017 16:30 #
Hi Bram, As Fabrice says the problem is multiple nodes being passed to the number function. The Xpath below returns nodes where this is true: //alpino_ds//node[ @rel="hd" and @pt="vz" and 1<count(../node[ @rel="obj1" and @cat="np" ]/node[ @rel="mod" and @cat="pp" ]/node[ @rel="hd" and @pt="vz" ]) ] In this case: [4196] <node begin="3" end="4" frame="preposition(aan,[vooraf])" id="10" lcat="pp" lemma="aan" pos="prep" postag="VZ(init)" pt="vz" rel="hd" root="aan" sense="aan" vztype="init" word="aan"/> Selecting the first match works for me - using the code as shown on SO. //alpino_ds//node[ @rel="hd" and @pt="vz" and number(@begin) < number( ( ../node[ @rel="obj1" and @cat="np" ]/node[ @rel="mod" and @cat="pp" ]/node[ @rel="hd" and @pt="vz" ]/@begin )[1] ) ]
Quoted text · Bram Vanroy · 457 lines
On 8 March 2017 at 13:57, Bram Vanroy <bram.vanroy1 at student.kuleuven.be> wrote: > Hi Fabrice and others > > > > I have been breaking my head over this the last few days and can’t get it > right. I tried your suggestion, but that does not work either. I have made > the data available for testing and added a question on Stack Overflow. > Anyone, feel free to help me out! [1] > > > > Thanks in advance! > > > > [1] http://stackoverflow.com/q/42673237/1150683 > > > > > > *Van:* Fabrice ETANCHAUD [mailto:fetanchaud at groupefbo.com] > *Verzonden:* maandag 6 maart 2017 9:14 > > *Aan:* Bram Vanroy <bram.vanroy1 at student.kuleuven.be>; 'BaseX' < > basex-talk at mailman.uni-konstanz.de> > *Onderwerp:* RE: [basex-talk] [XPTY0004] Item expected, sequence found > > > > Hello Bram, > > Sorry for the delay, > > > > It means there is more than one node element matching : > > > > *../node[* > > * @rel="obj1" and @cat="np"* > > * ]/node[* > > * @rel="mod" and @cat="pp"* > > * ]/node[* > > * @rel="hd" and @pt="vz"* > > * ]/* > > > > You could make you request work by taking for example only the first > @begin attribute : > > > > * and number(@begin) < number(* > > * ( ../node[* > > * @rel="obj1" and @cat="np"* > > * ]/node[* > > * @rel="mod" and @cat="pp"* > > * ]/node[* > > * @rel="hd" and @pt="vz"* > > * ]/@begin)[1])* > > ] > > > > But it may be meaningless with respect to your data. > > > > Hoping it will help, > > > > Best regards, > > Fabrice > > > > *De :* Bram Vanroy [mailto:bram.vanroy1 at student.kuleuven.be > <bram.vanroy1 at student.kuleuven.be>] > *Envoyé :* vendredi 3 mars 2017 19:39 > *À :* Fabrice ETANCHAUD <fetanchaud at groupefbo.com>; 'BaseX' < > basex-talk at mailman.uni-konstanz.de> > *Objet :* RE: [basex-talk] [XPTY0004] Item expected, sequence found > > > > Good evening Fabrice > > > > I have tried what you suggested, and indeed: when I replace the first > block the script works fine, and when I replace the second it does not. But > I’m not sure what this means, or how I can solve this in XPath? (I’m sorry, > I really am not good with XPath and XQuery.) > > > > I don’t know if this is relevant, but when I try the query with one slash > in the front instead of two, the script works fine as well. > > > > > > Thank you for the help so far! > > > > *Van:* Fabrice ETANCHAUD [mailto:fetanchaud at groupefbo.com > <fetanchaud at groupefbo.com>] > *Verzonden:* vrijdag 3 maart 2017 16:30 > *Aan:* Bram Vanroy <bram.vanroy1 at student.kuleuven.be>; 'BaseX' < > basex-talk at mailman.uni-konstanz.de> > *Onderwerp:* RE: [basex-talk] [XPTY0004] Item expected, sequence found > > > > Hello Bram, > > > > Sorry I mean it might not be xquery related, but xml related (in your > dataset). > > > > Maybe running a modified version of your script twice, > > Replacing separately each bold statement below with > > > > *and count(../node[* > > * @rel="obj1" and @cat="np"* > > * ]/node[* > > * @rel="mod" and @cat="pp"* > > * ]/node[* > > * @rel="hd" and @pt="vz"* > > * ]/@begin) > 1* > > > > Will help you identify where you have more than one matching element ? > > > > Best regards, > > Fabrice > > > > //node[ > > @cat="pp" > > and node[ > > @rel="hd" > > and @pt="vz" > > * and number(@begin) < number(* > > * ../node[* > > * @rel="obj1" and @cat="np"* > > * ]/node[* > > * @rel="mod" and @cat="pp"* > > * ]/node[* > > * @rel="hd" and @pt="vz"* > > *]/@begin)* > > ] > > and node[ > > @rel="obj1" > > and @cat="np" > > and node[ > > @rel="mod" > > and @cat="pp" > > and node[ > > @rel="hd" > > and @pt="vz" > > * and number(@begin) < number(* > > * ../node[* > > * @rel="obj1" * > > * and @cat="np"* > > * ]/node[* > > * @rel="mod" * > > * and @cat="pp"* > > * ]/node[* > > * @rel="hd" * > > * and @pt="vz"* > > * ]/@begin)* > > ] > > and node[ > > @rel="obj1" > > and @cat="np" > > and node[ > > @rel="mod" > > and @cat="pp" > > and node[ > > @rel="hd" > > and @pt="vz" > > ] > > ] > > ] > > ] > > ] > > ] > > > > > > > > > > *De :* Bram Vanroy [mailto:bram.vanroy1 at student.kuleuven.be > <bram.vanroy1 at student.kuleuven.be>] > *Envoyé :* vendredi 3 mars 2017 12:52 > *À :* Fabrice ETANCHAUD <fetanchaud at groupefbo.com>; 'BaseX' < > basex-talk at mailman.uni-konstanz.de> > *Objet :* RE: [basex-talk] [XPTY0004] Item expected, sequence found > > > > Hi Fabrice thank you for the quick reply. > > > > Unfortunately I do not understand what you mean. I have queried other > XPath codes with the number() function and the begin attribute without > fault. However, it does seem to point in that direction as the error > explicitly mentions that attribute: > > > > attribute begin {"6"}, > > > > Because other lines in the benchmark with the number() function and begin > attribute do not throw this error, I do not know where to look. > > > > *Van:* Fabrice ETANCHAUD [mailto:fetanchaud at groupefbo.com > <fetanchaud at groupefbo.com>] > *Verzonden:* vrijdag 3 maart 2017 12:33 > *Aan:* Bram Vanroy <bram.vanroy1 at student.kuleuven.be>; 'BaseX' < > basex-talk at mailman.uni-konstanz.de> > *Onderwerp:* RE: [basex-talk] [XPTY0004] Item expected, sequence found > > > > Hi Bram > > > > From what one can read there : > > > > http://docs.basex.org/wiki/XQuery_Errors > > > > It seems to me that number() function could be called with a sequence of > @begin. > > There might be a place in your query where multiple node elements are > returned, leading to a node/@begin sequence. > > > > Best regards, > > Fabrice > > > > > > *De :* basex-talk-bounces at mailman.uni-konstanz.de [ > mailto:basex-talk-bounces at mailman.uni-konstanz.de > <basex-talk-bounces at mailman.uni-konstanz.de>] *De la part de* Bram Vanroy > *Envoyé :* vendredi 3 mars 2017 12:19 > *À :* 'BaseX' <basex-talk at mailman.uni-konstanz.de> > *Objet :* [basex-talk] [XPTY0004] Item expected, sequence found > > > > Hi BaseX peeps > > > > I’m running BaseX 8.6.1 on Windows, and I’m running into an issue I can’t > explain. I am using BaseX to run some benchmarks. As a benchmark I am > running different XPath structures to match on the same database. In other > words, in a file of a hundred lines each line is an XPath structure, and > with Perl I query each line and measure the time it takes. Simple enough, > right? > > > > The strange thing is that my script runs fine but it crashes on line 17, > which is this XPath code: > > > > //node[@cat="pp" and node[@rel="hd" and @pt="vz" and number(@begin) < > number(../node[@rel="obj1" and @cat="np"]/node[@rel="mod" and > @cat="pp"]/node[@rel="hd" and @pt="vz"]/@begin)] and node[@rel="obj1" and > @cat="np" and node[@rel="mod" and @cat="pp" and node[@rel="hd" and @pt="vz" > and number(@begin) < number(../node[@rel="obj1" and > @cat="np"]/node[@rel="mod" and @cat="pp"]/node[@rel="hd" and > @pt="vz"]/@begin)] and node[@rel="obj1" and @cat="np" and node[@rel="mod" > and @cat="pp" and node[@rel="hd" and @pt="vz"]]]]]] > > > > Admittedly, it’s quite a long string, but I don’t see anything wrong with > it and I don’t think the error lies in the XPath. The full trace is like > follows: > > > > [XPTY0004] Item expected, sequence found: (attribute begin {"6"}, ...). at > C:\xampp\htdocs\grinding\BaseXClient.pm line 213. > > at C:\xampp\htdocs\grinding\BaseXClient.pm line 213. > > Query::exc("\x{5}", 133) called at C:\xampp\htdocs\grinding\BaseXClient.pm > line 177 > > Query::execute(Query=HASH(0x3adac40)) called at SonarBenchNew.pl > line 249 > > main::query_sonar("for \$node in db:open(\" > WRPEE0000000treebank\")/treebank//node[\@"...) called at SonarBenchNew.pl > line 176 > > main::loop_databases(ARRAY(0x31a2ae0), "//node[\@cat=\"pp\" and > node[\@rel=\"hd\" and \@pt=\"vz\" and number(\@"...) called at > SonarBenchNew.pl line 140 > > main::regular_sonar("//node[\@cat=\"pp\" and node[\@rel=\"hd\" > and \@pt=\"vz\" and number(\@"...) called at SonarBenchNew.pl line 110 > > > > I have found that the XPTY0004 error is often caused by an order-by clause > in XQuery but I don’t have that. The full XQuery for the XPath is as > follows: > > > > for $node in db:open("WRPEE0000000treebank")/treebank//node[@cat="pp" and > node[@rel="hd" and @pt="vz" and number(@begin) < number(../node[@rel="obj1" > and @cat="np"]/node[@rel="mod" and @cat="pp"]/node[@rel="hd" and > @pt="vz"]/@begin)] and node[@rel="obj1" and @cat="np" and node[@rel="mod" > and @cat="pp" and node[@rel="hd" and @pt="vz" and number(@begin) < > number(../node[@rel="obj1" and @cat="np"]/node[@rel="mod" and > @cat="pp"]/node[@rel="hd" and @pt="vz"]/@begin)] and node[@rel="obj1" and > @cat="np" and node[@rel="mod" and @cat="pp" and node[@rel="hd" and > @pt="vz"]]]]]]let $sentid := ($node/ancestor::alpino_ds/@id)let $sentence > := ($node/ancestor::alpino_ds/sentence)let $tb := > \'WRPEE0000000treebank\' return <match>{data($sentid)}||{data( > $sentence)}||{data($tb)}</match> > > > > I don’t know if you guys can give me directions solely based on this. But > if you could point me to a likely cause, e.g. input OR database contents, > that would be great. > > > > > > Thanks in advance! > > > > Bram Vanroy > > https://bramvanroy.be >

⚡Generated with XQuery