The bug is pinpointed in XPath.pm 2.017, so Text.pm should not be patched and the XML::Twig version (3.22 or later) doesn't matter .
The fix will be done in the next O::O release. However, in the meantime, the existing XPath.pm should be manually replaced by a provisional one, which is now available at
http://jean.marie.gouarne.online.fr/tech/oodoc/XPath.pm