Re: Help on XML Schema generation using XSLT

Michael Kay <[email protected]>
Newsgroups gmane.text.xml.schema.devel
Message-ID <[email protected]>
  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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.