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

Re: Help on XML Schema generation using XSLT

From: Silent lights <silentlights@yahoo.co.uk>
Date: Tue, 31 Aug 2010 14:50:29 +0000 (GMT)
Message-ID: <892232.97145.qm@web24205.mail.ird.yahoo.com>
To: Michael Kay <mike@saxonica.com>, Matthieu Ricaud-Dussarget <matthieu.ricaud@igs-cp.fr>
Cc: Edward A SSG RES USAR USARCCheney <austin.cheney@us.army.mil>, xmlschema-dev@w3.org
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="."/>

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 ?


--- On Fri, 20/8/10, Matthieu Ricaud-Dussarget <matthieu.ricaud@igs-cp.fr> wrote:

> From: Matthieu Ricaud-Dussarget <matthieu.ricaud@igs-cp.fr>
> Subject: Re: Help on XML Schema generation using XSLT
> To: "Michael Kay" <mike@saxonica.com>
> Cc: "Cheney, Edward A SSG RES USAR USARC" <austin.cheney@us.army.mil>, "Silent lights" <silentlights@yahoo.co.uk>, xmlschema-dev@w3.org
> Date: Friday, 20 August, 2010, 12:50
> Hi Densil,
> I think it's a pretty good idea, especially the one to use
> a collection of xml file to better detect the global XML
> structure. We can admit the assertion that if one need a
> schema, it means that we should have more than one file on
> this type.
> XSLT, as functionnal language may be quite helpful, and
> using XSLT2 might help more. And as long as I know, if you
> use a Java XSLT processor, you can call java classes within
> your xslt. Then you are no more restricted
> functionnal/procedural (but well your xslt will not be
> plateform independant anymore...).
> Do you already now what kind of "schema" you like to
> generate ?
> It might be a very different analyse in case you want to
> generate a DTD, a W3C-schema or a RelaxNG one.
> I've done something similar for Relax NG, but it's a dummy
> XSLT  : it only generate elements with attributes in
> the order then come, no guesswork.. euh heuristics ;)
> But within the xml input you can add a few lines of RelaxNg
> which will be reproduced (within the generated elements or
> inverse).
> It don't think it's what you want. Its actually just a tool
> to write schema easyer and faster, because one only interact
> with the structure logic, not the obvisous things. But you
> can customize everythings (the more you do, the less
> automatic it is, and finaly your could almost write the
> schema yourself in the xml and the tool become unusefull)
> And at last, I think XMLspy has a W3C-schema generator, I
> don't know how it is implemented.
> Jedit has a DTD generator (XML plugin), which might be
> written in java (or/and XSLT ?) and is open source :)
> Let us know about this interresting project.
> Matthieu Ricaud-Dussarget.
> Le 20/08/2010 10:22, Michael Kay a écrit :
> > On 20/08/2010 00:58, Cheney, Edward A SSG RES USAR
> USARC wrote:
> >> Densil,
> >> 
> >> I would say converting a basic XML document to a
> schema document is not probable unless there exists a
> certain quantity of known information
> > 
> > 
> > Actually there are a number of tools that do a quite
> passable job of generating a schema from an instance,
> including my own DTDGenerator from many years ago (still
> available on the Saxon page at Sourceforge). It demands some
> guesswork (or if we want to be more polite, heuristics) but
> it's possible to do a surprisingly good job. For example, my
> DTDGenerator uses ruled like "generate an enumeration type
> if there are less than 20 distinct values and the number of
> actual values is at least ten times the number of distinct
> values". Of course the inferred schema will always be
> imperfect (it will allow some "invalid" documents, and
> disallow some "valid" ones, where "validity" is in the eye
> of the user) so it will need manual adjustment.
> > 
> > Although there are quite a few such tools around, I'm
> not aware of any that are implemented in XSLT. But I think
> it would be perfectly reasonable to attempt to write one in
> > 
> > I've always thought it would be a good idea for such a
> tool to allow multiple source instances to be supplied as
> input. In practice I've handled this by concatenating them
> within a wrapper element.
> > 
> > Michael Kay
> > Saxonica
> > 
> > 
> -- Matthieu Ricaud
> Service Livre numérique

Received on Tuesday, 31 August 2010 14:57:42 UTC

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