Re: Help on XML Schema generation using XSLT

  On 31/08/2010 3:50 PM, Silent lights wrote:
> Hi there,
> I am trying to solve one issue here.. How do I check for the data type for an element and its attribute..
>
> I tried something like,
>
> <xsl:if test="not(string(.) castable as xs:integer)">
>        <xsl:text>Following value is not an integer:</xsl:text>
>        <xsl:value-of select="."/>
>      </xsl:if>
>
> but looks like it doesnt work on XSLT 1.0 and XPath 1.0.. Is there a way to check the data type for integer, decimal, string and boolean perhaps ?
>
There's no easy way in XSLT 1.0. You'll have to do it the hard way, by 
actually parsing the value against the lexical rules, using the limited 
machinery available of translate(), substring-before(), 
substring-after(), and so on. You could start by testing to see whether 
number(x) returns NaN.

Michael Kay
Saxonica

Received on Tuesday, 31 August 2010 15:30:22 UTC