XQuery: Error "Effective boolean value not defined for array (*): [true ()]."

0

I intend to make a query about an XML document whose structure is as follows:

<bib>
    <libro anyo="1994">
        <titulo>TCP/IP Ilustrado </titulo>
        <autor>
            <apellido>Stevens</apellido>
            <nombre>W.</nombre>
        </autor>
        <editorial>Prentice-Hall</editorial>
        <precio>65.95</precio>
    </libro>
    <libro anyo="1992">
        <titulo>Programación Avanzada en el entorno Unix</titulo>
        <autor>
            <apellido>Stevens</apellido>
            <nombre>W.</nombre>
        </autor>
        <editorial>Prentice-Hall</editorial>
        <precio>65.95</precio>
    </libro>
    <libro anyo="2000">
        <titulo>Datos en la Web</titulo>
        <autor>
            <apellido>Abiteboul</apellido>
            <nombre>Serge</nombre>
        </autor>
        <autor>
            <apellido>Buneman</apellido>
            <nombre>Peter</nombre>
        </autor>
        <autor>
            <apellido>Suciu</apellido>
            <nombre>Dan</nombre>
        </autor>
        <editorial>Morgan Kaufmann</editorial>
        <precio>39.95</precio>
    </libro>
    <libro anyo="1991">
        <titulo>Economía de la Tecnología y el Contenido de la TV digital</titulo>
        <editor>
            <apellido>Gerbarg</apellido>
            <nombre>Darcy</nombre>
        </editor>
    </libro>
    </bib>

As you can see, the author W. Stevens appears in two books ( TCP / IP Illustrated and Advanced Programming in the Unix environment ).

The goal of the first clause FLOWR is to extract a single instance of the author element if its child elements have the same content

for $a in doc("libros.xml")/bib/libro/autor
group by $nom:=$a/nombre, $ape:=$a/apellido
return <autor>
          <nombre>{
             concat($a[1]/nombre,' ',$a[1]/apellido)
          }</nombre>
          <libro>{
            for $b in doc("libros.xml")/bib/libro
            where $b/autor/[nombre eq $a[1]/nombre]
            return $b/titulo
        }</libro>
       </autor>

Specifically, in the second clause FLOWR (line 10) I get the following error:

  

[FORG0006] Effective boolean value not defined for array (*): [true ()].

The purpose of this second clause FLOWR is to return the content of the title element, belonging to the book element, where the element author matches the author who is currently iterating through the first clause FLOWR

What could this error be?

I already made a publication with a question about XQuery, well, I have another doubt, effect of that publication. If I make a different publication, it is because I believe that the doubt is of another kind

    
asked by JD0001 28.03.2017 в 19:38
source

1 answer

0

This question has just been resolved by my teacher by mail. Anyway, I publish the solution that you have offered me for those that you find interesting.

We can think that this error is due to the existence of a libro element where there is more than one element autor , it will fail to have positive multiple in the condition where

  

[FORG0006] Effective boolean value not defined for array (*): [true ()].

The solution to this problem is to apply the following structure: where some $c in $b satisfies $c=$a .

In this way it is achieved that, once the condition is met, regardless of the times it is fulfilled, it will return the content of the element //libro/titulo of those books where the element autor/nombre equals the one stored at that moment in the variable a[1] .

Without further delay, the code of the second FLOWR :

<libro>{
             for $b in doc("libros.xml")/bib/libro
             where some $c in $b/autor satisfies $c/nombre=$a[1]/nombre
             return $b/titulo
          }</libro>
    
answered by 29.03.2017 в 12:48