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

Re: Help on XML Schema generation using XSLT

From: Silent lights <silentlights@yahoo.co.uk>
Date: Thu, 9 Sep 2010 14:53:16 +0000 (GMT)
Message-ID: <65500.63638.qm@web29610.mail.ird.yahoo.com>
To: Michael Kay <mike@saxonica.com>
Cc: Matthieu Ricaud-Dussarget <matthieu.ricaud@igs-cp.fr>, Edward A SSG RES USAR USARCCheney <austin.cheney@us.army.mil>, xmlschema-dev@w3.org
Hi Michael and all,
I was able to do the checking on numbers, boolean and the rest I treated as string. Like,

<xsl:template name="getType">
		<xsl:param name="curr"/>
		<xsl:param name="dType"/>
		<xsl:choose>
			<!-- Test if it is a Number -->
			<xsl:when test="number($curr) = number($curr)">
				<xsl:value-of select="concat($dType, 'xs:integer')"/>
			</xsl:when>
			<!-- Test if it is a Boolean -->
			<xsl:when test="contains('/true/True/TRUE/false/FALSE/False/',concat('/',$curr,'/')) and string-length ($curr) &lt; 5">
				<xsl:value-of select="concat($dType, 'xs:boolean')"/>
				<!--<xsl:value-of select="boolean"/>-->
			</xsl:when>
			<!-- It is a String -->
			<xsl:otherwise>
				<xsl:value-of select="concat($dType, 'xs:string')"/>
				<!--<xsl:value-of select="string"/>-->
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>

I was wondering if there is a way to distinguish between decimals and date. 

I am generating this Schema and I have an output document (XSD). I like to consider this as a second input and check it with another incoming XML document. - means I have two input documents. Is there any way to handle something like document containers..? any suggestions on how such things would be done !? 

Thank you
Densil

--- On Tue, 31/8/10, Michael Kay <mike@saxonica.com> wrote:

> From: Michael Kay <mike@saxonica.com>
> Subject: Re: Help on XML Schema generation using XSLT
> 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
> Date: Tuesday, 31 August, 2010, 17:29
>  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 Thursday, 9 September 2010 14:53:50 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 14:56:18 UTC