Re: Error message to reconsider

Michael Kay <mike-JkSD5nQpfvpWk0Htik3J/[email protected]> Fri, 2 Oct 2020 20:50:03 +0100
Newsgroups gmane.text.xml.saxon.help
Message-ID <[email protected]>
This is a classic problem with design of error messages: the expressions $map(x) and map:get($map, x) are 100% equivalent, except that you want to produce different error messages if there's a dynamic error. The obvious strategy is to compile both expressions to the same runtime code, but then they will also produce the same errors. It's complicated here by the fact that the lookup expression $map?(x) provides get another way of expressing the same semantics.

But good error messages are important, and I'll take a look to see what can be done.

Michael Kay
Saxonica

> On 2 Oct 2020, at 20:01, Ihe Onwuka <[email protected]> wrote:
> 
> This is a  reprefixing function. It takes a qualified name, strips off the prefix and looks up the namespace for the prefix using the variable containing the root element as it's context. Having got the namespace it is supposed to decode that in a map to a preferred prefix.  
> 
>    <xsl:variable name="fRePrefix" as="function(xs:string) as xs:string"
>                  select="function($name as xs:string) as xs:string {
>                          namespace-uri-for-prefix(substring-before($name,':'),$root) => $nsMap() || ':'
>                          }"/>
> 
> The call fails because the namespace I am looking up isn't in scope on the root so it doesn't pass anything to the map which is represented by a global variable $nsMap. The problem is the error message which you might want to look at. 
> 
> Type error at char 111 in expression in xsl:variable/@select on line 35 column 31 of test.xsl:
>   XPTY0004  An empty sequence is not allowed as the second argument of map:get()
> at function anon:f_1617838096 on line 0
>      invoked by unknown caller (class net.sf.saxon.functions.hof.UserFunctionReference$BoundUserFunction)
> at function anon:f_1617838096 on line 0
> An empty sequence is not allowed as the second argument of map:get()
> _______________________________________________
> saxon-help mailing list archived at http://saxon.markmail.org/
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/saxon-help

_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[email protected]
https://lists.sourceforge.net/lists/listinfo/saxon-help