-
-
Notifications
You must be signed in to change notification settings - Fork 190
Description
Is your feature request related to a problem? Please describe.
I frequently encounter errors when I use functions that require URLs and URIs to be typed as xs:anyURI
—instead of, as is the case in the standard function library, xs:string
(see fn:collection
, which "interpret[s] $arg as an xs:anyURI", fn:doc
, fn:doc-available
, fn:json-doc
; the standard functions may return xs:anyURI
when appropriate but never require this type in parameters). The xs:anyURI
requirement, while a correct description of the expected content, doesn't actually provide much benefit. On the other hand, it imposes a moderate burden on XQuery coders.
Describe the solution you'd like
I would propose a review of the modules that do this and raise these for consideration by the community. Questions could include:
- Does the parameter really need to be
xs:anyURI
? - Is this function so different from
fn:doc
, etc. that it merits the additional developer burden on XQuery coders? - Would the function not work as well if it were relaxed to
xs:string
?
If we can identify functions that can adopt the same behavior as the standard function library, perhaps the function signatures of these could be adjusted to allow xs:string
and to "interpret" this argument "as an xs:anyURI
" (to borrow a phrase from the spec for fn:collection
).
Describe alternatives you've considered
The alternative would be to take no action.
Additional context
The following query generates a list of all built-in, java-based functions that take a parameter typed as xs:anyURI
:
xquery version "3.1";
declare namespace xqdoc="http://www.xqdoc.org/1.0";
<div>{
for $sig in collection("/db/apps/fundocs/data")//xqdoc:signature[matches(., "as xs:anyURI[\?\*\+]?[,\)]")]
let $function := $sig/..
let $xqdoc := $sig/ancestor::xqdoc:xqdoc
let $module := $xqdoc/xqdoc:module
let $module-name := ($module/xqdoc:name/string(), "fn")[normalize-space(.) ne ""][1]
let $module-uri := $module/xqdoc:uri
where starts-with($xqdoc/xqdoc:control/xqdoc:location, "java:")
group by $module-name
order by $module-name
return
<div>
<p><strong>{$module-name} ({head($module-uri)/string()})</strong></p>
<ol>{
for $s in $sig
order by $s
return
<li>{analyze-string($s, "xs:anyURI")/* ! (if (self::fn:match) then <strong>{string(.)}</strong> else text{.})}</li>
}</ol>
</div>
}</div>
Here's the list:
exrest (http://exquery.org/ns/restxq/exist)
- exrest:deregister-module($module as xs:anyURI) as document-node()
- exrest:deregister-resource-function($module as xs:anyURI, $function-signature as xs:string) as xs:boolean
- exrest:find-resource-functions($module as xs:anyURI) as document-node()
- exrest:register-module($module as xs:anyURI) as document-node()
- exrest:register-resource-function($module as xs:anyURI, $function-signature as xs:string) as xs:boolean
image (http://exist-db.org/xquery/image)
- image:thumbnail($collection as xs:anyURI, $thumbnail-location as xs:anyURI?, $dimension as xs:integer*, $prefix as xs:string?) as xs:string*
inspect (http://exist-db.org/xquery/inspection)
- inspect:inspect-module($location as xs:anyURI) as element()?
- inspect:inspect-module-uri($uri as xs:anyURI) as element()?
- inspect:module-functions($location as xs:anyURI) as function(*)*
- inspect:module-functions-by-uri($uri as xs:anyURI) as function(*)*
response (http://exist-db.org/xquery/response)
- response:redirect-to($uri as xs:anyURI) as empty-sequence()
session (http://exist-db.org/xquery/session)
- session:encode-url($url as xs:anyURI) as xs:anyURI
sm (http://exist-db.org/xquery/securitymanager)
- sm:add-group-ace($path as xs:anyURI, $group-name as xs:string, $allowed as xs:boolean, $mode as xs:string) as empty-sequence()
- sm:add-user-ace($path as xs:anyURI, $user-name as xs:string, $allowed as xs:boolean, $mode as xs:string) as empty-sequence()
- sm:chgrp($path as xs:anyURI, $group-name as xs:string) as empty-sequence()
- sm:chmod($path as xs:anyURI, $mode as xs:string) as empty-sequence()
- sm:chown($path as xs:anyURI, $owner as xs:string) as empty-sequence()
- sm:clear-acl($path as xs:anyURI) as empty-sequence()
- sm:get-account-metadata($username as xs:string, $attribute as xs:anyURI) as xs:string?
- sm:get-group-metadata($group-name as xs:string, $attribute as xs:anyURI) as xs:string?
- sm:get-permissions($path as xs:anyURI) as document-node()
- sm:has-access($path as xs:anyURI, $mode as xs:string) as xs:boolean
- sm:insert-group-ace($path as xs:anyURI, $index as xs:int, $group-name as xs:string, $allowed as xs:boolean, $mode as xs:string) as empty-sequence()
- sm:insert-user-ace($path as xs:anyURI, $index as xs:int, $user-name as xs:string, $allowed as xs:boolean, $mode as xs:string) as empty-sequence()
- sm:modify-ace($path as xs:anyURI, $index as xs:int, $allowed as xs:boolean, $mode as xs:string) as empty-sequence()
- sm:remove-ace($path as xs:anyURI, $index as xs:int) as empty-sequence()
- sm:set-account-metadata($username as xs:string, $attribute as xs:anyURI, $value as xs:string) as empty-sequence()
- sm:set-group-metadata($group-name as xs:string, $attribute as xs:anyURI, $value as xs:string) as empty-sequence()
util (http://exist-db.org/xquery/util)
- util:declare-namespace($prefix as xs:string, $namespace-uri as xs:anyURI) as item()
- util:import-module($module-uri as xs:anyURI, $prefix as xs:string, $location as xs:anyURI*) as item()
validation (http://exist-db.org/xquery/validation)
- validation:pre-parse-grammar($grammar as xs:anyURI*) as xs:string*
xmldb (http://exist-db.org/xquery/xmldb)
- xmldb:decode-uri($uri as xs:anyURI) as xs:string
- xmldb:get-mime-type($resource-uri as xs:anyURI) as xs:string?
- xmldb:set-mime-type($resource-uri as xs:anyURI, $mime-type as xs:string?) as empty-sequence()
xqdm (http://exist-db.org/xquery/xqdoc)
- xqdm:scan($uri as xs:anyURI) as node()*
zip (http://expath.org/ns/zip)
- zip:binary-entry($href as xs:anyURI, $entry as xs:string) as xs:base64Binary
- zip:entries($href as xs:anyURI) as node()
- zip:html-entry($href as xs:anyURI, $entry as xs:string) as document-node()
- zip:text-entry($href as xs:anyURI, $entry as xs:string) as xs:string
- zip:update($href as xs:anyURI, $paths as xs:string+, $binaries as xs:base64Binary+) as xs:base64Binary?
- zip:xml-entry($href as xs:anyURI, $entry as xs:string) as document-node()