xsl-list
[Top] [All Lists]

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

2010-11-09 09:18:31
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(_at_)hotmail(_dot_)com> 
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?  Or something else/better?

I've approx 500 XML source files where parts of each one need placing into a 
database.  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

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--