W3C home > Mailing lists > Public > xmlschema-dev@w3.org > August 2010

Re: Help on XML Schema generation using XSLT

From: Michael Kay <mike@saxonica.com>
Date: Tue, 31 Aug 2010 16:29:47 +0100
Message-ID: <4C7D1FEB.8090208@saxonica.com>
To: Silent lights <silentlights@yahoo.co.uk>
CC: Matthieu Ricaud-Dussarget <matthieu.ricaud@igs-cp.fr>, Edward A SSG RES USAR USARCCheney <austin.cheney@us.army.mil>, xmlschema-dev@w3.org
  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
Received on Tuesday, 31 August 2010 15:30:22 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 23:15:57 UTC