Re: [xsl] What the default datatype of an stylesheet parameter ?

Subject: Re: [xsl] What the default datatype of an stylesheet parameter ?
From: Matthieu Ricaud-Dussarget <matthieu.ricaud@xxxxxxxxx>
Date: Fri, 25 Nov 2011 10:23:53 +0100
Thank you for your as-always clear explanation Michael.

I work more and more with strong datatype in XSLT2, which make the code stronger, I'll do always declare a datatype pour stylesheet params.. and as I always use Saxon I know how it behaves now.
Really usefull tip for boolean parameters !


After testing this, let me just add that the if the supply parameter cannot be casted to the declared type, saxon raise an error.
I don't know how other xslt processors behaves in regard to this point, and sorry that my question is a bit "implementation dependant".


Thank you for your response Ken, but as said Michael my question was about "always supplied parameters".
But this make me think about another question : if no parameters is supplied, I'm use to test it againts empty string with
<xsl:if test="$foo=''"/>
and it usually works.
Is an empty sequence equal to an emty string?
(maybe the equal operator tries to cast both part to the same type ?


Regards,
Matthieu.

Le 25/11/2011 01:06, Michael Kay a icrit :
On 24/11/2011 23:31, G. Ken Holman wrote:
At 2011-11-24 21:19 +0100, Matthieu Ricaud-Dussarget wrote:
When sending a parameter to the stylesheet( from command line with saxon for example), I thought it was always a string (which is a pitty when you need boolean parameter).

I made a simple test, sending "bar" to parameter foo :
<xsl:param name="foo"/>

In XSLT 1, that is, indeed, an empty string as you anticipated. In XSLT 2, however, that is the declaration of an empty sequence.
I think Ken is answering a different question - what is the default value of the parameter? If you don't supply a value, $foo will indeed be the empty sequence.

Michael Kay
Saxonica




--
Matthieu Ricaud
IGS-CP
Service Livre numirique

Current Thread