From: Peter W. <pet...@ke...> - 2012-12-21 10:54:35
|
Hi I'm trying to find a method of getting a program to branch depending on the parameter provided. After determining the selection, the following processes are identical. The following code will only provide data for $name-predicate. If I change the order, it works for a $place-predicate only. I presume from this that this particular use of a conditional clause is invalid. What alternatives do I have for achieving the desired result? (Apart from separate XQueries which is where I am at the moment. I've also tried putting alternatives into the predicate which according to Presley p 46 does seem to be legitimate - see below, but that does not work either). Best wishes Peter let $name-predicate := local:get-name-predicate(request:get-parameter('people','')) let $place-predicate := local:get-name-predicate(request:get-parameter('place','')) let $selected-documents := (if($name-predicate) then (collection('/db/punch/data')//tei:persName[@corresp=$name-predicate]) else if($place-predicate) then (collection('/db/punch/data')//tei:placeName[@corresp=$place-predicate]) else ()) return $selected-documents Alternative predicate: let $selected-documents := collection('/db/punch/data')//(if($name-predicate) then tei:persName[@corresp=$name-predicate] else tei:placeName[@corresp=$place-predicate] ) return $selected-documents * Version: 2.0-tech-preview * SVN Revision: 15855 * Build: 20120228 |