>
> [FORG0001] Cannot convert xs:string to xs:anyURI: "
> HTtpS://reGexr.com/more/less/path/foo.p....
>

Your URI string contains invalid characters. The first query yields a
result, the second doesn’t:

  xs:anyURI("[")
  xs:anyURI("%5b")

There are various ways to get this cleaned up. For example, you can use
fn:encode-for-uri [1]. Or have a look at the web:create-url convenience
function of BaseX:

  web:create-url(
    'HTtpS://reGexr.com/more/less/path/foo.php',
    map { 'q': 'bar', 'same[12]': 'xxx' }
  )

[1] https://www.w3.org/TR/xpath-functions-31/#func-encode-for-uri
[2] http://docs.basex.org/wiki/Web_Module#web:create-url







> 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.gr...@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
>>
>>
>>
>
> --
> Minden jót, all the best, Alles Gute,
> Andreas Mixich
>

Reply via email to