-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
QName arguments: also allow strings #1661
Comments
We could additionally introduce mutual coercion of strings and QNames:
|
Note also in XSLT, Despite this, I have some hesitation in increasing the number of places where the static namespace context has to be retained at execution time. |
I'm starting to come around to extending the coercion rules so that if the required type is xs:QName, a string that can be converted to a QName by calling fn:parse-QName should be accepted. I have reservations about doing this in dynamic function calls, however, where it isn't statically known what the required type will be; we don't want to have to retain the static namespace for a dynamic function call just in case. |
To understand this correctly:
|
I think that in general, we know statically which parts of the static context are needed by an expression, and we only need to retain those parts when compiling the expression. Retaining the static namespace context for every dynamic function call, just in case it turns out to have QNames in the function signature, would be very expensive. It's possible to make economies by noting that the static context of an expression is in many cases the same as its parent expression, but that kind of thing makes expression rewrites such as loop-lifting more complex. |
I could imagine that the incurred costs are implementation-specific, but maybe I should first implement it before judging it (if I remember correctly, we simply keep a reference to an existing static context in dynamic functions). In any case, most function calls are certainly static, so it would already be a good improvement to support those. |
In #747, a syntax for QName literals was proposed (
Q"prefix:local"
). Concerns were raised that the new syntax could be mixed up with the existingQ{URI}local
syntax, and that too many syntax variants are confusing.In attribute and element constructors, it is already possible to supply
prefix:local-name
andQ{uri}local
strings for names:With option declarations, it is possible to write:
…and it is counterintuitive that
serialize($xml, { 'cdata-section-elements': 'xml' })
is not legal.I wonder whether we cannot simply allow both QNames and strings for arguments (and arguments in options) in the existing standard functions. There are fewer cases than I had suspected:
fn:error
$code
fn:format-number
$options
:format-name
(can also bexs:NCName
)fn:deep-equal
$options
:unordered-elements
fn:serialize
$options
:cdata-section-elements
,suppress-indentation
fn:function-lookup
$name
fn:load-xquery-module
$options
:variables
,vendor-options
fn:transform
$options
:initial-function
,initial-mode
,initial-template
, ...fn:elements-to-maps
$options
:layouts
fn:schema-type
$name
For some options, like the
method
option offn:serialize
, we already allow both strings and QNames.The text was updated successfully, but these errors were encountered: