[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] Trying to understand root-less or document-node-less nodes


Subject: Re: [xsl] Trying to understand root-less or document-node-less nodes
From: Abel Braaksma <abel.online@xxxxxxxxx>
Date: Mon, 17 Sep 2007 20:43:03 +0200

Andrew Welch wrote:
On 9/17/07, Abel Braaksma <abel.online@xxxxxxxxx> wrote:
Hi David, thanks for your response.
It was from me Abel... :)

oops, sorry! I need new glasses!



It's important to realise what happens when you add as="element()+" to
a variable definition - I've been caught out by it before when typing
all of my variables.

and I now by not typing the variables, or, for that matter, the result of my functions.... I'll get a red card from MK for that!


<xsl:variable name="root" as="document-node()">

...so in this case I decided that the "as" attribute can be left off
(this is the exception to the rule of "always use the as attribute").

but, when teaching, it is perhaps better to make it explicit. As in a typed language, you don't want a variable that is meant to be a string to be treated as type Object, Any or Base (depending on your language) just because you forgot to add the type. Instead, you teach your pupils to *always* add a type, even when you explicitly want it to be of type Object (or document-node() in the above example).


The start of the thread where DC explains it is here:
http://www.oxygenxml.com/archives/xsl-list/200607/msg00880.html

Aha, so there was some 'David' along the line. Thanks for the pointer! (and the clear explanations).


Cheers,
-- Abel Braaksma


Current Thread