Saturday, 19 November 2011

performance

dynamic-path is the killer   50%   1158
app:td hardcoded to return td 
 50%   1441
declare function app:td($item, $field-def) as element(td) {
     (: path default to name  :)
   
             let $path:=($field-def/@path,concat('@',$field-def/@name))[1]
             let $data:="test"
             (: let $data:=data(functx:dynamic-path($item,$path)) :)
             let $x :=
                 if($field-def/@type='id' and $field-def/@link)
                 then  app:hyperlink(concat($field-def/@link,"/",$data),string($data)) 
                 else $data
         
             let $d:={
                 (if($field-def/@type=('integer','float'))
                 then attribute class {'r'}
                 else ''
                 ,$x)
             }
                  
             return $d 
};
Working solution
declare function app:data($item , $path as xs:string) {
    let $f:=app:fpath($path)
    return data($f($item))
 };
 
declare function app:fpath($path){
   util:eval(concat("function($item){$item/",$path,"}"))
}; 

No comments:

Post a Comment