I use this idiom quite often:

for $node in $thousands-of-nodes
let $n := $node/path/to/@n
return
  if ($n)
  then $n
  else do-something-else()

But one can say this instead:

for $node in $thousands-of-nodes
return
  if ($node/path/to/@n)
  then $node/path/to/@n
  else do-something-else()

As a general rule, is it better to declare a variable and use it in the
if test and then clause, or to use a path in both places? Maybe there is
a better idiom?

Best

Tim Finney
Programmer
University of Virginia Press

_______________________________________________
General mailing list
[email protected]
http://xqzone.com/mailman/listinfo/general

Reply via email to