In the example code in section 17.1.5 there are three calls to fn:length() that should be to fn:string-length(). Reprted today by Dr. Axel Polleres, Digital Enterprise Research Institute (DERI) on the public-qt-comments list.
Erratum E32 has been drafted to fix this. The problem is accordingly being marked as fixed.