Re: [xsl] Generating XSD Schema files from XML source files

Subject: Re: [xsl] Generating XSD Schema files from XML source files
From: Mukul Gandhi <gandhi.mukul@xxxxxxxxx>
Date: Tue, 9 Nov 2010 20:47:58 +0530
I agree with everything what Mike has said.

Adding to Mike's explanation, here's a little example illustrating
some of the issues you might face with this task.

Let's say there is an instance XML document like following:

<x>100</x>

Then all the below XML schema fragments will successfully validate the
above instance document:

<xs:element name="x" type="xs:integer" />

<xs:element name="x" type="xs:positiveInteger" />

<xs:element name="x" type="xs:int" />

or even

<xs:element name="x">
    <xs:simpleType>
        <xs:restriction base="xs:integer">
           <xs:maxInclusive value="1000" />
        </xs:restriction>
    </xs:simpleType>
</xs:element>

For more involved XML documents, difficulty of this task may increase
exponentially :)

On Tue, Nov 9, 2010 at 7:56 PM, Neil Owens <neil_owens@xxxxxxxxxxx> wrote:
>
>
> I have a need to generate XSD Schema files from source XML files and I've no
idea what would be the current 'best practice' way to go about it?
>
> Just write an XSL transform that does the XML result file to Output and the
schema to a result-document?B  Or something else/better?
>
> I've approx 500 XML source files where parts of each one need placing into a
database.B  What I've done so far, with Saxon9 and XSLT2, combined with this -
http://msdn.microsoft.com/en-us/library/ms171806.aspx - does it all, except
generating the Schema file.
>
> TIA!




--
Regards,
Mukul Gandhi

Current Thread