From: marhoumi f. e. <zah...@ya...> - 2006-08-13 12:39:04
|
I tried to execute this xquey with XQueryService in a Java application: xquery version "1.0"; declare namespace xmldb="http://exist-db.org/xquery/xmldb"; declare namespace request="http://exist-db.org/xquery/request"; declare namespace util="http://exist-db.org/xquery/util"; declare function local:month($d as item()) as item()* { let $d1 := tokenize(string($d), "-") return <month> { if ($d1[2] = "01") then "Jan" else if ($d1[2] = "02") then "Feb" else if ($d1[2] = "03") then "Mar" else " " } </month> }; declare function local:insert($s as xs:string) as item()* { for $sale in //sales[@state = data($s)]/sale let $p :=//ProductFamily[Product/@id = $sale/sku_id] let $new := <fact> <state_id>{data($s)}</state_id> <sku_id>{data($sale/sku_id)}</sku_id> <supplier_id>{data($p/@supplier_id)}</supplier_id> {local:month($sale/time)} <sales>{data($sale/sales)}</sales> </fact> return if (every $fact in //fact satisfies $fact/state_id != data($s) or $sale/sku_id != $fact/sku_id or $fact/month != data(local:month($sale/time))) then update insert $new into //facts else <Result> Les ventes de l'état {data($sale/state)} du produit {data($sale/sku_id)} pour le mois de {data(local:month($sale/time))} existent deja dans le Data Warehouse</Result> }; for $state in ('California', 'Florida', 'Louisiana', 'Oregon') return local:insert($state) and I got this exception: unexpected token: $ [at line 1, column 226] although this query works perfectly with the eXist user interface !!!! PS: other queries where no local functions are not defined work in my Java application !!, maybe that's the problem. can some one, please help me to solve this problem ? Fatima. --------------------------------- Découvrez un nouveau moyen de poser toutes vos questions quelque soit le sujet ! Yahoo! Questions/Réponses pour partager vos connaissances, vos opinions et vos expériences. Cliquez ici. |