W3C home > Mailing lists > Public > public-qt-comments@w3.org > March 2015

[Bug 28196] [F+O3.1] Do the function conversion rules apply to parameters in option maps?

From: <bugzilla@jessica.w3.org>
Date: Thu, 12 Mar 2015 08:23:19 +0000
To: public-qt-comments@w3.org
Message-ID: <bug-28196-523-rO5vUQrzH0@http.www.w3.org/Bugs/Public/>

--- Comment #1 from Michael Kay <mike@saxonica.com> ---
To take an example of the problem, consider a call that attempts to delete all
invalid characters from JSON input by doing:

parse-json($in, map{'fallback':function($s){""}})

It turns out this doesn't work, because the function is the wrong type. It has
to be written

parse-json($in, map{'fallback':function($s as xs:string) as xs:string {""}})

The extra verbiage is all telling the system what it could easily work out for

A pragmatic solution might be to relax the required type, so instead of

function($s as xs:string) as xs:string

the required type becomes

function($s as xs:string) as item()*

and we then specify what happens dynamically if the returned value isn't a
single string. The first call above then becomes legal. There are precedents
for this, for example fn:remove() takes xs:integer rather than
xs:positiveInteger as the second argument, to allow the function to be called
more easily.

You are receiving this mail because:
You are the QA Contact for the bug.
Received on Thursday, 12 March 2015 08:23:21 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 16:57:53 UTC