From: Hungerburg <pc...@my...> - 2010-09-11 09:57:53
|
Happy Hackers, I wanted to output json that is readily consumable by dojo-data, and eXist made this a quick adventure. code below, for any other newbees that struggle with xquery. Now if only I could get eXist to enforce uniqueness for the id attribute of all documents in namespace "produkt" below the "data" directory in my application. I'd rather not manage uploads by a controller, but preferred to upload via webdav or http put. I toyed around with triggers to some success. any ideas on this? ########### code/ (: find all products with a matching @code, return some dojo-data consumable json :) let $hits := collection($coll)//produkt:produkt[ft:query(@code, $query)] let $count := count($hits) let $result := <result> <identifier>id</identifier> <label>titel</label> <count>{$count}</count> { for $item in $hits return <items> <id>{string($item/@id)}</id> <code>{string($item/@code)}</code> <titel>{string($item/produkt:titel1)}</titel> </items> } </result> return json:xml-to-json($result) ########### /code Thank you -- peter |