Under some circumstances, when an xs:anyURI value is
supplied as an argument to a function whose required
type is String, a compile-time type error (XPTY0004)
The problem occurs where it is not apparent during
initial type checking that the supplied value is an
xs:anyURI, but where this becomes apparent later as a
result of contextual analysis: for example, if the
argument is written as a path expression and analysis
of the path expression against a schema reveals that
the supplied value will be an xs:anyURI.
Circumvention: cast the value explicitly to a string,
using the string() function.
[Source code fixed, test cases satype001 and