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@groupefbo.com]
Verzonden: vrijdag 3 maart 2017 12:33
Aan: Bram Vanroy <bram.vanroy1@student.kuleuven.be>; 'BaseX' <basex-talk@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@mailman.uni-konstanz.de [mailto:basex-talk-bounces@mailman.uni-konstanz.de] De la part de Bram Vanroy
Envoyé : vendredi 3 mars 2017 12:19
À : 'BaseX' <basex-talk@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