Hi,

I’m using BaseX to compare two XML documents with a list of items <asset> identified by an element <assetid> and with a

Now I need to consolidate them in only one document with the value of the <category> element in both documents (one of them renamed to <prev-category>).

Attached are samples of these documents., and the quey I’m using is this:

declare function local:compare( $actual, $prev ){

  for $c in $actual/asset

    return <asset>

        { $c/*}

        <prev-category>

        { $prev/asset[assetid = $c/assetid]/category/text() }

        </prev-category>

    </asset> 

};

 

declare variable $act external := "2017-07";

declare variable $prv external := "2016-07";

return local:compare(/portfolio[projectid=$act], /portfolio[projectid=$prv] )

The query takes 42 seconds when run over the files. If I load the files to a database and activate the text index, it takes 125 seconds.

This is a very common query in relational databases that takes only few seconds to run joining two tables or two subqueries.

Is there a way to make it run faster in BaseX?

Thanks for your advice,

 

 

William David Velásquez

Creativo de Software

Creativos Digitales S.A.S.

Calle 30A # 83 - 53 Local 1033

Tel: 322 1730 - 311 709 8421

Medellín, Colombia

http://creativosdigitales.co