[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: testing for string and number in XSLT 2.0 was Re:

Subject: Re: testing for string and number in XSLT 2.0 was Re: Test For Numeric Values?
From: James Fuller <jim.fuller@xxxxxxxxxxxxxx>
Date: Fri, 08 Apr 2005 13:32:51 +0200
xslt isnumber
>The xsl:analyze-string construct could be written more simply as
>
><xsl:value-of select="matches($select, '[\d]+')"/>
>  
>
i like the matches() function...neat

>>this is fine and dandy in a basic XSLT 2.0 processor, and potentiall
>>could be extended, though I find it uncomfortable that xsl:function
>>automatically casts my params as xs:string when there is no 
>>declaration,
>>    
>>
>
>It doesn't. If you don't declare the types of your parameters then they
>actual values supplied in the function call are passed through unchanged.
>
>  
>
ok understand, btw I assume that tunnel params are not in affect within
params in xsl:functions....

>>so doing something like the following (in an XSLT 2.0 
>>processor that is
>>schema aware).
>>
>>
>>        Test X (xs:integer) matching string
>>        using istype:<xsl:value-of select="type:istype($x,'number')"/>
>>        using isnumber:<xsl:value-of select="type:isnumber($x)"/>
>>        using isstring:<xsl:value-of select="type:isstring($x)"/>
>>    
>>
>
>This doesn't require a schema-aware processor, you aren't doing anything
>here that's not available in a basic processor
>  
>
ok..yes David just corrected me


>>will through out an error, I guess I could employ the 
>>use-when attribute
>>to check for schema conformance (does this exist as a system 
>>property?).
>>    
>>
>
>Yes it does but you don't need it here
>  
>
>>btw, does anyone else find it weird that xsl:function doesnt have the
>>ability to prescribe a return type ?...I wanted to return a boolean
>>type...
>>    
>>
>
>Then (a) declare the type
>
><xsl:function name="x" as="xs:boolean">
>  
>

yes just discovered this as well...feels right, though once again not
the use of XML Schema datatypes....or the option not to use them.

>and (b) return a value of that type
>
><xsl:sequence select="matches($arg, '\d+')"/>
>
>In fact, I think the function you want is:
>
><xsl:function name="type:is-number" as="xs:boolean">
>  <xsl:param name="arg" as="xs:string"/>
>  <xsl:sequence select="matches($arg, '\d+')"/>
></xsl:function>
>
>  
>
so explain to me the scenario

    <xsl:variable name="x" select="example/test[1]" as="xs:integer"/>

<xsl:function name="type:is-number" as="xs:boolean">
  <xsl:param name="arg" as="xs:string"/>
  <xsl:sequence select="matches($arg, '\d+')"/>
</xsl:function>

hehe, no pls dont answer that! really I understand now; 

the fact that BASIC conformance meant XML Schema datatypes are still being used completely went under my radar...so I now understand that value for BASIC conformance is directed towards implementators...

many thx for taking the time to answer my lame questions.

jim

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.