Re: [xsl] type error on 3rd argument of key function

Subject: Re: [xsl] type error on 3rd argument of key function
From: Ihe Onwuka <ihe.onwuka@xxxxxxxxx>
Date: Thu, 14 Feb 2013 17:27:49 +0000
On Thu, Feb 14, 2013 at 5:18 PM, Martin Honnen <Martin.Honnen@xxxxxx> wrote:
> Ihe Onwuka wrote:
>>
>>   <xsl:variable name="formats" as="element()+">
>>          <lookup:format from="eps" to="image"/>
>>          <lookup:format from="gif" to="image"/>
>>          <lookup:format from="jpg" to="image"/>
>> </xsl:variable>
>>
>> Assuming the above is correctly typed and I have the following key
>> declaration
>>
>> <xsl:key name="formats" match="lookup:*/@to" use="../@from"/>
>>
>> Then the following invocation fais
>>
>> key('formats',xfile/@format,$
>> formats)
>>
>> with the error
>>
>> A sequence of more than one item is not allowed as the third argument
>> of key().......
>>
>> But if I untype the $format variable (remove the as attribute from the
>> $format variable), it works.
>>
>> Experienced this on Saxon 9.1.0,7 and 9.3.0.5.
>
>
> You could use
>   as="document-node()"
> if you want to use an "as" attribute to type annotate the variable.
>
> I don't think keys work with sequences, you need a root node.
>

Typing it as document-node() does not work. I am happy to leave it
untyped as it works mind.

Current Thread