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:[email protected]]
Envoyé : vendredi 3 mars 2017 19:39
À : Fabrice ETANCHAUD <[email protected]>; 'BaseX' 
<[email protected]>
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:[email protected]]
Verzonden: vrijdag 3 maart 2017 16:30
Aan: Bram Vanroy 
<[email protected]<mailto:[email protected]>>; 
'BaseX' 
<[email protected]<mailto:[email protected]>>
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:[email protected]]
Envoyé : vendredi 3 mars 2017 12:52
À : Fabrice ETANCHAUD 
<[email protected]<mailto:[email protected]>>; 'BaseX' 
<[email protected]<mailto:[email protected]>>
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:[email protected]]
Verzonden: vrijdag 3 maart 2017 12:33
Aan: Bram Vanroy 
<[email protected]<mailto:[email protected]>>; 
'BaseX' 
<[email protected]<mailto:[email protected]>>
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 : 
[email protected]<mailto:[email protected]>
 [mailto:[email protected]] De la part de Bram Vanroy
Envoyé : vendredi 3 mars 2017 12:19
À : 'BaseX' 
<[email protected]<mailto:[email protected]>>
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

Reply via email to