I thought that the simpler expression below with a decent optimizer
will be as efficient as the above:
exists($context[normalize-space()])
as it is sufficient to find the first non-empty text() descendent to
conclude that the argument to the exists() function is the $context
element.
Saxon does part of this optimization - normalize-space() in a boolean context
is evaluated by scanning the string until a non-whitespace character is found
(effectively rewriting as a function call contains-non-whistespace()).
It doesn't do the other half, recognizing that
contains-non-whitespace($element) can be evaluated as
exists($element//text()[contains-non-whitespace(.)]).
There's always scope for more such optimizations, but there's a law of
diminishing returns. It's not unusual to find that some such optimization isn't
triggered by a single one of the 30,000 QT3 test cases, and then you have to
ask whether it's worth implementing.
Michael Kay
Saxonica
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--