Subject: Re: [xsl] [XSL 3.0] Function that check if a xs:string can be converted as a xs:double From: "Michael Kay mike@xxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Wed, 31 May 2023 23:40:59 -0000 |
Just to clarify: this is not a feature that has been specified in the current draft of XPath 4.0. Making types into first class values would indeed be nice, but the work to define it has not yet been started, let alone finished. Michael Kay Saxonica > On 31 May 2023, at 21:19, Dimitre Novatchev dnovatchev@xxxxxxxxx <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote: > > In XPath 4.0 this could be: > > fn:castable-as := function($in as xs:string, $typeName as xs:string) > { fn:op("castable as") ($in, $typeName ) } > > or just: > > fn:castable-as := fn:op("castable as") > > and this function could be chained within a sequence of other functions. > > but I don't think we at present allow "castable as" as a possible argument value of fn:op > > What would also be more desirable is to have a type-object (not a type-name as xs:string) as the 2nd function parameter and in the language. > > A type object can have such useful associated functions as parse() and show() (print / serialize), that one wouldn't even need to have a special function checking if a value is parsable to a given type. Just parse it and act correspondingly to the result. Having a type object passed as parameter one could specify a series of generic operations on any value of that type. > > Thanks, > Dimitre > > On Wed, May 31, 2023 at 4:57b/AM Christophe Marchand cmarchand@xxxxxxxxxxxxxx <mailto:cmarchand@xxxxxxxxxxxxxx> <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx <mailto:xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>> wrote: > Hello ! > > I have to write a function taht take a xs:string as parameter, returns a xs:boolean, and says true() if string is a valid number, false() otherwise. > > Something like > > <xsl:function name="f:isNumber" as="xs:boolean"> > <xsl:param name="expression" as="xs:string"/> > <xsl:sequence select="....."/> > </xsl:function> > '1' -> true() > '2' -> true() > 'foo' -> false() > 'bar' -> false() > Rules to be a valid number are the same as those used in number() function. > > Any help wil be much appreciated ! > > Christophe > > XSL-List info and archive <http://www.mulberrytech.com/xsl/xsl-list> > EasyUnsubscribe <http://lists.mulberrytech.com/unsub/xsl-list/782854> (by email <applewebdata://A84CCB4C-9792-4E3D-9068-E399E59A63F9>) > > > XSL-List info and archive <http://www.mulberrytech.com/xsl/xsl-list> > EasyUnsubscribe <http://lists.mulberrytech.com/unsub/xsl-list/3500899> (by email <>)
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] [XSL 3.0] Function that c, Dimitre Novatchev dn | Thread | [xsl] preserving the base URI origi, Chris Papademetrious |
Re: [xsl] [XSL 3.0] Function that c, Dimitre Novatchev dn | Date | |
Month |