Ah, hi Gustavo,
I actually don't know this, but it seems that the implementation of XQuery
in eXist places your results in an unsorted list! Or possibly it is placed
in a hashmap with its own bindings representing, for instance, data types
and so on?
Thinking about this, I believe it is possible to sort your returned results
using XQuery, and I think that must be your best alternative since your
function returns strings, which is what you want to display immiediately.
There is the option of further wrapping the results. I guess you have the
problem of how to sort though, i.e. on what basis. Once again I don't know,
but you may have to circumvent the whole problem with a sort of wrapper,
placing your results in a hashmap and calling a further XQuery function on
that hashmap for each result you want. If so not very pretty and leads me to
think there must be a "proper" way of doing this!
Does this make sense?

Adam

2008/9/20 Gustavo Corral <[EMAIL PROTECTED]>

> Hi list,
>
> I have some days with a problem and I hope anybody can help me. I have
> developed an extension module to search documents in an eXist collection
> using Lucene. The module works fine and returns a Sequence with all the
> documents matching a query sorted by the score of Lucene, but when I call
> the function of the module in an XQuery script, the documents don't appear
> in the same order.
>
> I have this function which take an array with the document's names as
> argument and returns a NodeSet with this documents from eXist collection:
>
> protected static NodeSet getDocuments(String[] cgDocNames, DBBroker broker)
> throws XPathException
>    {
>        //Creamos una Secuencia para almacenar los resultados
>        ExtArrayNodeSet documents = new ExtArrayNodeSet(cgDocNames.length,
> 1);
>
>        //obtiene la coleccion de reportes
>        Collection cdData =
>
> broker.getCollection(XmldbURI.create(JReportsModule.REPORTSDIRECTORY_DATA_COLLECTION));
>
>        //itera sobre los nombres de reportes
>        for(int i = 0; i < cgDocNames.length; i ++)
>        {
>            //System.out.println(cgDocNames[i]);
>
>            DocumentImpl cgDoc = cdData.getDocument(broker,
> XmldbURI.create(cgDocNames[i].substring(cgDocNames[i].indexOf("
> ")+1,cgDocNames[i].length())));
>            if(cgDoc != null){
>                //aƱade el reporte a la secuencia de resultados
>                documents.add(new NodeProxy(cgDoc));
>            }
>        }
>        documents.sort(true);
>        return (NodeSet) documents;
>    }
>
> In the eval function of the extension module I call this getDocuments
> function and that's the Sequence eval returns. Until this moment it seems
> the documents are in the correct order, but when I call the function of the
> extension module in an XQuery script the documents are returned in unorder.
>
> Is the description clear? because my english is not very good.
>
> Thanks
>

Reply via email to