XML Schema Definition Tool (xsd.exe)

XML Schema Definition (XSD) is useful when working with XML schemas that follow the XSD language. With XSD, you can perform the following transformations:

  • XDR to XSD

  • XML to XSD

  • Classes to XSD

  • XSD to Classes

  • XSD to DataSet

XDR to XSD

To convert an XDR-formatted file to XSD, you would use the following syntax:

xsd [options] file.xdr

Note that the file extension .xdr dictates the conversion from XDR to XSD.

XML to XSD

To convert an XML-formatted file to XSD, you would use the following syntax:

xsd [options] file.xml

Note that the file extension .xml dictates the conversion from XML to XSD.

Classes to XSD

You can convert classes to XSD by specifying the runtime assembly file (.exe or .dll extension) as the filename to the utility. You can also specify a particular type within the assembly you want to convert to XSD using the /type flag. The typename can be a wildcard match. If you omit the /type flag, all types in the assembly will be converted. The syntax follows:

Xsd [/TYPE:typename] assemblyFile

or:

Xsd [/T:typename] assemblyFile

XSD to Classes

To convert XSD back to classes, use the /classes or /c flag. You can specify a particular element in the XSD schema to be converted to a class. You can also specify the language for the class source file. The general syntax follows:

xsd /CLASSES 
    /ELEMENT:element 
    /NAMESPACE:namespace
    /LANGUAGE:language /URI:uri file.xsd

or:

xsd /C E:element /N:namespace /L:language /U:uri file.xsd

Note that namespace, language, and uri ...

Get .Net Framework Essentials now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.