Where clause causes trouble

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Where clause causes trouble

McAuley, Grant (LLU)
Hello,

I posted a similar message, but different in significant details, about
two weeks ago.  I was using the 2005-05-09 snapshot and now have tried
this with the 2005-08-05 snapshot, apparently with the same results:

When I run my test xquery (below) as is, the 'School 1' and 'Year 1'
data cells are empty in the resulting table.  When I remove the 'where'
clause these cells are populated (as they should be).

I see the same behavior if a try a simpler 'where' clause (e.g., 'where
$alum[@attend = 'yes']' ).  So, it seems like using a 'where' clause
causes problems.

My questions are:

1) is this is a know issue
2) is there a work-around, and/or
3) am I doing something wrong?

This problem is causing a big delay in a current project, so any help
would be greatly appreciated.


///XQuery/////////////////////////


declare function local:getTableRows($intl as xs:string, $brunch as
xs:string, $country as xs:string) as element()* {

        let $col := collection("/db/mycol")
        for $alum in $col/alumnus
        let $countries := $alum//country/text()
      where
                $alum[@attend = 'yes'] and
                $brunch = ($alum/@brunch, 'either') and
                $intl = ($alum/service/@intl, 'either') and
                $country = ($countries, 'all')

        order by $alum/degrees/degree[1]/school,
$alum/degrees/degree[1]/year
        return
        <tr>
                <td>{ $alum/name/text() }</td>
                <td>{ $alum/degrees/degree[1]/school/text() }</td>
                <td>{ $alum/degrees/degree[1]/year/text() }</td>
              <td>{ string($alum/service/@intl) }</td>
                <td>{ string($alum/@brunch) }</td>
                <td>{ ($alum//country/text()) }</td>
                               
        </tr>

};

<html>
<body>
{
        let $x := ()
        return
                <table width="100%" border="3" cellspacing="3"
cellpadding="3" id="data">
                        <tr>
                          <th>Name</th>
                          <th>School 1 </th>
                          <th>Year 1 </th>
                          <th>Intl</th>
                          <th>Brunch</th>
                          <th>Countries</th>

                        </tr>
                        { local:getTableRows('either', 'either', 'all')
}
                </table>
}
</body>
</html>

//////////////////////////////////


///Sample Data////////////////////

//-----------------------

<?xml version="1.0" encoding="UTF-8"?>
<alumnus attend="yes" number="1" brunch="yes">
    <name>John Doe</name>
    <degrees>
        <degree>
            <school>Graduate</school>
            <year>1964</year>
        </degree>
        <degree>
            <school>Graduate</school>
            <year>1978</year>
        </degree>
    </degrees>
    <address>...</address>
    <phone>...</phone>
    <email>[hidden email]</email>
    <service intl="yes">
        <countries>
            <country>Mexico</country>
            <country>Ecuador</country>
            <country>China</country>
        </countries>
        <summary>...</summary>
    </service>
</alumnus>

//-------------------------

<?xml version="1.0" encoding="UTF-8"?>
<alumnus attend="yes" number="2" brunch="yes">
    <name>Sally Smith</name>
    <degrees>
        <degree>
            <school>Public Health</school>
            <year>1976</year>
        </degree>
        <degree>
            <school>Allied Health</school>
            <year>1972</year>
        </degree>
    </degrees>
    <address>...</address>
    <phone>...</phone>
    <email>[hidden email]</email>
    <service intl="yes">
        <countries>
            <country>Chile</country>
            <country>Mexico</country>
            <country>Peru</country>
        </countries>
        <summary>...</summary>
    </service>
</alumnus>

//-------------------------


-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
Exist-open mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/exist-open
Reply | Threaded
Open this post in threaded view
|

Re: Where clause causes trouble

wolfgangmm
Hi,

there seems to be another error with respect to positional predicates.
The workaround is to use

$alum/degrees/degree[position() = 1]

instead of

$alum/degrees/degree[1]

But I'll try to fix the bug.

Wolfgang


-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
Exist-open mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/exist-open