So, I just came around this:
declare variable $local:uri as xs:anyURI := xs:anyURI(" HTtpS://reGexr.com/more/less/path/foo.php?q=bar&same[12]=xxx&same[11]=#sldns13123nfdwdw "); $local:uri
The error I get is
[XPST0003] Invalid entity: '&same[12]=xxx&same[1...'.
so I encoded the '&' to '&'.
declare variable $local:uri as xs:anyURI := xs:anyURI(" HTtpS://reGexr.com/more/less/path/foo.php?q=bar&same[12]=xxx&same[11]=#sldns13123nfdwdw "); $local:uri
which results in:
Error: Stopped at C:/Users/user/Desktop/file3, 1/55: [FORG0001] Cannot convert xs:string to xs:anyURI: " HTtpS://reGexr.com/more/less/path/foo.p....
The only way I found to circumvent this, was to encode it via the entity reference and then use encode-for-uri(), but that function/topic seems to be a beast for itself...
On Mon, Aug 13, 2018 at 7:25 PM Christian Grün christian.gruen@gmail.com wrote:
whenever I define the type of a parameter as xs:anyURI and pass a
string to it, I get the error "Cannot convert xs:string to xs:anyURI".
It might comfort you to hear that the behavior is indeed compliant with the spec. As it would take some time to recite the reasons for this, feel free to scan the following sections:
https://www.w3.org/TR/xquery-31/#id-function-conversion-rules https://www.w3.org/TR/xquery-31/#promotion
I should have added, that this also does not succeed:
...
which leaves me even more baffled.
Me too, because the following query works on my environment:
declare variable $local:uri1 as xs:anyURI := xs:anyURI("http://example.com/batz/mongo/blah/index.html"); $local:uri1