[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

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

Subject: Re: when to use 'as' attribute on a variable
From: "tom tom" <tomxsllist@xxxxxxxxxxx>
Date: Wed, 08 Mar 2006 10:33:39 +0000
xsl function as
Thanks all for your help. More questions:

To store an external XML doc in a variable am I right in saying I should use document-node() ?
To store an nodeset taken from the XML in a variable I should use item()?
Then what is the node() type for and how is it different from item()?




From: "Dimitre Novatchev" <dnovatchev@xxxxxxxxx>
Reply-To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re:  when to use 'as' attribute on a variable
Date: Tue, 28 Feb 2006 07:16:27 +1100

> 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@xxxxxxxxxxx> 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
>
>



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


_________________________________________________________________
Are you using the latest version of MSN Messenger? Download MSN Messenger 7.5 today! http://messenger.msn.co.uk


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.