Re: Must variables that contain maps be typed?

Ihe Onwuka <[email protected]>
Newsgroups gmane.text.xml.saxon.help
Message-ID <CALfs7+z+G+z3c1FZqJfjVPmbE4uYt-Hwr3LwuPkXsHVdx6wgiQ@mail.gmail.com>
i thought the general rule was that it was never mandatory to specify a
type.


On Mon, Aug 17, 2020 at 11:02 AM Norman Tovey-Walsh <[email protected]> wrote:

> Ihe Onwuka <[email protected]> writes:
> > <xsl:variable name="actions" >
> >       <xsl:map>
> >             etc
> >      </xsl:map>
> > </xsl:variable>
> >
> > Doesn't seem right to me.
>
> As I recall, if you initialize a variable with a sequence constructor
> (content instead of a select attribute), then you are constructing a
> tree unless you specify a type.
>
> So,
>
>   <xsl:variable name="actions" select="map { … }"/>
>
> would be fine, but to use xsl:map, you have to specify the type:
>
>   <xsl:variable name="actions" as="map(*)">
>        <xsl:map>
>              etc
>       </xsl:map>
>   </xsl:variable>
>
> You could argue that the processor ought to be able to tell that the
> result is going to be a map, but keeping the rule simple means that
> there’s no possible ambiguity if someone constructs something that could
> be a map or could be a tree.
>
>                                         Be seeing you,
>                                           norm
>
> --
> Norman Tovey-Walsh <[email protected]>
> https://nwalsh.com/
>
> > There is hopeful symbolism in the fact that flags do not wave in a
> > vacuum.--Arthur C. Clarke
>

_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[email protected]
https://lists.sourceforge.net/lists/listinfo/saxon-help
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.