|
Subject: Re: [xsl] [XSL 3.0] Function that check if a xs:string can be converted as a xs:double From: "Dimitre Novatchev dnovatchev@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Wed, 31 May 2023 20:18:45 -0000 |
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
<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 <>)
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| Re: [xsl] [XSL 3.0] Function that c, Michael Kay mike@xxx | Thread | Re: [xsl] [XSL 3.0] Function that c, Michael Kay mike@xxx |
| Re: [xsl] preserving the base URI o, G. Ken Holman g.ken. | Date | Re: [xsl] [XSL 3.0] Function that c, Michael Kay mike@xxx |
| Month |