At 2011-11-25 10:23 +0100, Matthieu Ricaud-Dussarget wrote:
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".
Have you considered something along the lines of:
<xsl:variable name="arg-used" as="xs:whatever?"
select="if( $arg castable as xs:whatever )
then xs:whatever( $arg ) else ()"/>
.... $arg-used ...
Thank you for your response Ken, but as said Michael my question was
about "always supplied parameters".
Yes, please forgive my oversight.
But this make me think about another question : if no parameters is
supplied, I'm use to test it againts empty string with
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 ?
When the types are not the same, the processor reduces one or both of
the sides to a common type. The empty sequence is boolean false, and
the empty string is boolean false, so when both are converted to
boolean, they are the same.
I hope this helps.
. . . . . . . . . . Ken
Contact us for world-wide XML consulting and instructor-led training
Free 5-hour video lecture: XSLT/XPath 1.0 & 2.0 http://ude.my/t37DVX
Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/
G. Ken Holman mailto:gkholman(_at_)CraneSoftwrights(_dot_)com
Google+ profile: https://plus.google.com/116832879756988317389/about
Legal business disclaimers: http://www.CraneSoftwrights.com/legal
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>