xsl-list
[Top] [All Lists]

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

2011-11-25 03:24:08
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 écrit :
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

--~------------------------------------------------------------------
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>
--~--




--
Matthieu Ricaud
IGS-CP
Service Livre numérique


--~------------------------------------------------------------------
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>
--~--