xsl-list
[Top] [All Lists]

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

2011-11-24 17:38:31

This is outside the scope of the XSLT specification, and depends on the designer of the API. In Saxon, arguments are passed as xs:untypedAtomic values, and are then converted to the required type (if declared) using the standard function conversion rules. This means that if you declare the value as xs:integer (say), and pass the untypedAtomic value "3", it will be converted to an integer; if you declare the expected type as xs:boolean, then you can pass true, false, 0 or 1. If you don't declare the required type, the value will remain as an xs:untypedAtomic value - which is why ($foo instance of xs:string) is false.

Michael Kay
Saxonica


On 24/11/2011 20:19, Matthieu Ricaud-Dussarget wrote:
Hi all,

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"/>

I was really astonished to see that
$foo instance of xs:string
returns false()

I then typed the parameter :
<xsl:param name="foo" as="xs:string"/>
and got true()

What was the type of $foo before I casted it with as="xs:string" ?
Has it any type ...?

Thank for your lightening me :-)

Cheers,

Matthieu

PS : my bookmarks about that topic :
http://www.dpawson.co.uk/xsl/rev2/datatypes.html
http://www.w3.org/TR/xmlschema-2/#built-in-datatypes



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