xsl-list
[Top] [All Lists]

Re: when to use 'as' attribute on a variable

2006-02-27 13:16:27
1. when you should and should not be using an as attribute on xsl:variable
in XSLT 2

The right question is:

  Q: "when not to specify the type of an xsl:variable"

  A. Always do specify the type. Exceptions are extremely rare.

Even for such generic functions in FXSL as foldl(), the parameters
have specified type:

    <xsl:function name="f:foldl">
      <xsl:param name="pFunc" as="element()"/>
      <xsl:param name="pA0" as="item()*"/>
      <xsl:param name="pList" as="item()*"/>

      <xsl:sequence select=
             "if (empty($pList))
                  then
                      $pA0
                  else
                      f:foldl($pFunc,
                              f:apply($pFunc, $pA0, $pList[1]),
                              $pList[position() > 1]
                              )"/>
    </xsl:function>


This not only makes the code much more understandable, but in many
situations allows the compiler to catch and report errors, that
otherwise would have gone unnoticed.

One of the rare functions in FXSL, which has the type of its parameter
unspecified is

   f:type()

because it must determine and return the type of the argument.



Cheers,
Dimitre Novatchev


On 2/28/06, tom tom <tomxsllist(_at_)hotmail(_dot_)com> wrote:
Can anyone point me to some reliable documentation on:

1. when you should and should not be using an as attribute on xsl:variable
in XSLT 2

2. Which numerical datatype to use in which situation when declaring
variables holding numerical data.

Thanks in advance.

Tom

_________________________________________________________________
Be the first to hear what's new at MSN - sign up to our free newsletters!
http://www.msn.co.uk/newsletters


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--




--
Cheers,
Dimitre Novatchev
---------------------------------------
The significant problems we have cannot be solved at the same level of
thinking with which we created them.

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--