Subject: Re: [xsl] What the default datatype of an stylesheet parameter ? From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx> Date: Fri, 25 Nov 2011 05:05:58 -0500 |
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".
<xsl:variable name="arg-used" as="xs:whatever?" select="if( $arg castable as xs:whatever ) then xs:whatever( $arg ) else ()"/>
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 ?
-- 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@xxxxxxxxxxxxxxxxxxxx Google+ profile: https://plus.google.com/116832879756988317389/about Legal business disclaimers: http://www.CraneSoftwrights.com/legal
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] What the default datatype, Matthieu Ricaud-Duss | Thread | Re: [xsl] What the default datatype, Michael Kay |
Re: [xsl] What the default datatype, Matthieu Ricaud-Duss | Date | Re: [xsl] What the default datatype, Michael Kay |
Month |