xsl-list
[Top] [All Lists]

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

2011-11-25 04:42:07

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

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