Quantcast
Channel: XML, System.Xml, MSXML and XmlLite forum
Viewing all articles
Browse latest Browse all 935

Use xsd.exe to create XSD from XML without DataSet stuff

$
0
0

When I use the xsd.exe tool to create an XSD from an XML I get an XSD file with namespaces, tags and attributes for creating classes that use the DataSet class and related classes.

For example, with the following XML (file named sample.xml):

<?xml version="1.0"?><people  xmlns="http://tempuri.org/transformxml.xsd"><person born="1912" died="1954"><name><first_name>Alan</first_name><last_name>Turing</last_name></name><location>London</location><profession>computer scientist</profession><profession>mathematician</profession><profession>cryptographer</profession></person><person born="1918" died="1988"><name><first_name>Richard</first_name><middle_initial>M</middle_initial><last_name>Feynman</last_name></name><location>New York</location><profession>physicist</profession><hobby>Playing the bongoes</hobby></person></people>

If I do "xsd sample.xml" then I get:

<?xml version="1.0" encoding="utf-8"?><xs:schema id="people" targetNamespace="http://tempuri.org/transformxml.xsd" xmlns:mstns="http://tempuri.org/transformxml.xsd" xmlns="http://tempuri.org/transformxml.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" attributeFormDefault="qualified" elementFormDefault="qualified"><xs:element name="people" msdata:IsDataSet="true" msdata:UseCurrentLocale="true"><xs:complexType><xs:choice minOccurs="0" maxOccurs="unbounded"><xs:element name="person"><xs:complexType><xs:sequence><xs:element name="location" type="xs:string" minOccurs="0" msdata:Ordinal="1" /><xs:element name="hobby" type="xs:string" minOccurs="0" msdata:Ordinal="2" /><xs:element name="name" minOccurs="0" maxOccurs="unbounded"><xs:complexType><xs:sequence><xs:element name="first_name" type="xs:string" minOccurs="0" /><xs:element name="middle_initial" type="xs:string" minOccurs="0" /><xs:element name="last_name" type="xs:string" minOccurs="0" /></xs:sequence></xs:complexType></xs:element><xs:element name="profession" nillable="true" minOccurs="0" maxOccurs="unbounded"><xs:complexType><xs:simpleContent msdata:ColumnName="profession_Text" msdata:Ordinal="0"><xs:extension base="xs:string"></xs:extension></xs:simpleContent></xs:complexType></xs:element></xs:sequence><xs:attribute name="born" form="unqualified" type="xs:string" /><xs:attribute name="died" form="unqualified" type="xs:string" /></xs:complexType></xs:element></xs:choice></xs:complexType></xs:element></xs:schema>


I don't want any of that stuff in bold; the msdata stuff. The problem is that when I generate classes from an XSD like that I get code for use with the DataSet class and such and I want just plain classes. I could use some other tool to generate an XSD from XML but if the Microsoft XSD tool can be configured to do what I need then I want to know how.



Sam Hobbs
SimpleSamples.Info



Viewing all articles
Browse latest Browse all 935

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>