Pages

Thursday, March 26, 2009

XML Schema Definition Tool

XML Schema Definition Tool (Xsd.exe)

In many projects where Xml files are used, there can be a need to generate Xml schema
From an xml file and classes from schema file. We can use XML Schema Definition Tool (Xsd.exe) to generate Xml schema from XML file.

xsd Test.xml /outputdir:testOutputDir

where option "/outputdir:directory" specifies the directory for output files.

For Eg: xsd C:\Test.xml /outputdir:C:\Test which generates xsd schema file in C:\Test

To generate classes or dataset from an XSD schema file.

xsd file.xsd {/classes /dataset} [/element:element]
[/language:language] [/namespace:namespace]
[/outputdir:directory] [URI:uri]

Where
1) option "/classes" generates classes from an XSD schema file.
2) option "/dataset" generates dataset corresponding to XSD schema file.
3) option "/element" specifies the element in the schema for which code is generated.
4) option "/language" is used for specifying the language(C#, Visual Basic, Jscript, Visual J#)
5)option "/namespace" specifies the runtime namespace for the generated types. The default namespace is Schemas.
6) option "/outputdir:directory" specifies the directory for output files.
7) option "/URI:uri" specifies the URI for the elements in the schema to generate code for.

For Eg: xsd C:\Test\Test.xsd /classes /language:vb /outputdir:C:\Test which generates classes from an XSD schema file.



kick it on DotNetKicks.com

No comments: