From: Peter W. <pet...@ke...> - 2012-12-21 16:40:35
|
Thank you all. I'm going to have to think about the answers. But what I am finding is that where there is no $name-predicate it will not move on and take up a $place-predicate that is present. I'm only looking for one or the other, not both. Peter On 21/12/2012 12:22, Wolfgang Meier wrote: > Hi Peter, >> 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. > Isn't this what you would expect from an if statement? If $name-predicate is set, it will select the first clause and stop. You will always only get either the placeName or the persName elements returned. > > Please excuse if I'm misunderstanding what you are trying to do. I assume you want to search both, persName and placeName, if both parameters are set? In this case you need to combine the two selections, e.g. with a union: > > let $name-predicate := local:get-name-predicate(request:get-parameter('people','')) > let $place-predicate := local:get-name-predicate(request:get-parameter('place','')) > > > return > (if($name-predicate) then (collection('/db/punch/data')//tei:persName[@corresp=$name-predicate]) else ()) > union > (if($place-predicate) then (collection('/db/punch/data')//tei:placeName[@corresp=$place-predicate]) else ()) > > Wolfgang > |