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

Subject: Re: [xsl] What the default datatype of an stylesheet parameter ?
From: Michael Kay <mike@xxxxxxxxxxxx>
Date: Fri, 25 Nov 2011 10:41:58 +0000
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 ?



The '=' operator compares two sequences, and returns true if there is a pair of values, one from each sequence, that are equal to each other. If one of the sequences is empty, the result will always be false.


However, I may have misinformed you in my previous response. The specification says:

"If an optional parameter has no select attribute and has an empty sequence constructor, and if there is no as attribute, then the default value of the parameter is a zero length string."

This is why the test $foo='' is working for you.

The default value changes to an empty sequence if an "as" attribute is present to declare the type. In this case the test to apply is test="empty($foo)".

Michael Kay
Saxonica

Current Thread