DekGenius.com
[ Team LiB ] Previous Section Next Section

D.11 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

D.11.1 XDR to XSD

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

xsd [options] file.xdr

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

D.11.2 XML to XSD

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

xsd [options] file.xml

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

D.11.3 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

D.11.4 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 can be specified only once.

D.11.5 XSD to DataSet

To convert XSD to dataset, use the /dataset or /d flag. Again, you can narrow down to a particular element in the XSD schema to be converted. The general syntax follows:

xsd /D [/DATASET] file.xsd
    [ Team LiB ] Previous Section Next Section