Page tree

xsd2code++ can also be used with the command-line tool for batch conversion needs. For example in case of a large volume of schemas to convert.

Step-by-step guide

  1. Run cmd.exe
  2. cd C:\Program Files (x86)\xsd2code
  3. Run Xsd2Code.exe <XSD File> [Namespace] [Output file name] [Options]


Usage:

Xsd2Code.exe <XSD File> [Namespace] [Output file name] [Options]

Where:
<XSD File> - Path to an XSD file. Required
[Namespace] - Generated code namespace. Optional. File
name without extension if no value is
specified
[Output file name] - Name of the output (generated) file.Optional.
[Options] - Optional. See below for description

Options:
/o[utput] <FileName>
Name of the output (generated) file.
By default, name of the source file with extension .Designer.cs

/n[s] <Namespace>
Generated code CLR namespace. Default: file name without extension

/lic[ense] <License Path>
directory that contains the license file : xsd2code.license (Optional).
useful if executed by a build process that does not work under a standard user account.
ex. Xsd2Code.exe myxsd.xsd mynamespace mycs.cs /lic "c:\licenseFolder"

/l[anguage] <Language>
Generated code language (cs|vb). Default: cs

/pl[atform] <Platform>
Generated code target platform (Net20|Net30|Net35|Net40|Silverlight|WinRT|Xamarin).

/c[ollection] <Collection Base>
Collection base (Array|BindingList|List|ObservableCollection
|DefinedType,<Custom Collection Type>). Default: List

/cu[customusings] <Custom Usings1,Custom Usings2>
Comma-separated of custom usings definition
(E.g "Xsd2Code.Library,System.Xml.Linq")

------------------------
Options (serialzation) :
------------------------
/s
/is[+]
Enable serialization
/s-
/is-
Do not Enable Serialize method (default)

/xml
Use XmlSerializer to (de)serialize (/is is needed)

/javascript
Use JavaScriptSerializer to (de)serialize (/is is needed)

/json
Use JSonSerializer to (de)serialize (/is is needed)

/msgpack
Use MessagePackSerializer to (de)serialize (/is is needed)

/encUTF8
Enable UTF8 encoding in serialize methods (/is is needed)

/encUTF32
Enable UTF32 encoding in serialize methods (/is is needed)

/encASCII
Enable ASCII encoding in serialize methods (/is is needed)

/encDefault
Enable default encoding in serialize methods (/is is needed)

/encUnicode
Enable Unicode encoding in serialize methods (/is is needed)

/bigencUnicode
Enable BigEndianUnicode encoding in serialize methods (/is is needed)

/sm <Serialize>
Serialize method name. Default: Serialize (/is is needed)

/dm <Deserialize>
Deserialize method name. Default: Deserialize (/is is needed)

/lf[m] <LoadFromFile>
LoadFromFile method name. Default: LoadFromFile (/is is needed)

/sf[m] <SaveToFile>
SaveToFile methodname. Default: SaveToFile (/is is needed)

/in[dent]
/in[+]
Indent in output xml file (/is is needed)
/in-
Do not indent in output xml file (xml on single line. /is is needed)

/Indent1Space
Indent xml with 1 space (/in is needed)

/Indent2Space
Indent xml with 2 space (/in is needed)

/Indent3Space
Indent xml with 3 space (/in is needed)

/Indent4Space
Indent xml with 4 space (/in is needed)

/IndentTab
Indent xml with tab char (/in is needed)

/nla
NewLineOnAttributes, each attribute is pre-pended with a new line and one extra level of indentation

/oxml
Omit xml header

/xa[+]
Generate xml attributes (default)
/xa-
Do not generate xml attributes

/xao[+]
Generate xml order attributes (/xa is needed)
/xao-
Do not generate order xml attributes (default)

/ssp+
Generate ShouldSerilizeProperty method for nullable type
/ssp[-]
Do not generate ShouldSerilizeProperty method (default)

------------------------
Options (Class) :
------------------------
/cpublic (or empty)
Public access modifier (E.g public class)

/cinternal
Public access modifier (E.g internal class)

/cprefix
Class name prefix (E.g [StartWith]ClassName)

/cpsuffix
Class name suffix (E.g ClassName[EndWith])

/cpartial[+]
Generate partial class (default)
/cpartial[-]
Do not generate partial class

----------------------
Options (Properties) :
----------------------
/lazy
Enable property lazy loading

/pascalcase
Enable PascalCase property

/vprop
Enable Virtual property

/sc[+]
Enable summary comment
/sc-
Disable summary comment (default)

/appinfo[+]
Enable custom setting from appinfo xml
/appinfo-
Disable custom setting from appinfo xml (default)

/cache[+]
Enable caching for extenal schemas
/cache-
Disable caching for extenal schemas (default)

/if[+]
Enable initialization of fields (default)
/ifc[+]
Enable initialization of fields only for collections
/ifo[+]
Enable initialization of fields only for non optional elements
/if-
Disable all field initialization constructor or lazy

/emt[+]
Exclude types from external Schemas in generation
/emt-
Generate types from external schemas (default)

/uct[+]
Generate unused complex type
/uct-
Do not generate unused complex type (default)

/expattg
Expand nested attributeGroup inside xsd source

/gbc[+]
Use Generic Base Class
/gbc-
Do not use Generic Base Class (default)

/ggbc[+]
Generate Generic Base Class (default)
/ggbc-
Do not Generate Generic Base Class

/gbcn[ame] <ClassName>
Specifies the name of the base class. (Default:EntityBase)

------------------
Options (others) :
------------------

/cl[+]
Include Clone method
/cl-
Do not include Clone method (default)

/dbg[+]
/debug[+]
Enable debug step through (default)

/dbg-
/debug-
Disable debug step through

/warn
/warn[+]
Enable warning
/warn-
Disable warning (default)

/db[+]
Enable data bindings
/db-
Disable data bindings (default)

/dc[+]
Generate WCF data contract attributes
/dc-
Do not generate WCF data contract attributes (default)

/dmnAll
Generate always name for DataMemberAttribute

/dmnOnlyIfDiff
Generate name for DataMemberAttribute only if different thant XmlElementName

/dmnNever
No name specified for DataMemberAttribute

/dmxmli[+]
Generate WCF DataMember also on properties with XmlIgnoreAttribute
/dmxmli-
Do not generate WCF data contract attributes (default)

/rt[+]
Enable restriction attributes
/rt-
Disable restriction attributes (default)

/rtrange
Enable restriction RangeAttribute attributes

/rtregex
Enable restriction RegularExpressionAttribute attributes

/rtstlength
Enable restriction StringLengthAttribute attributes

/valprop
Validate property in setter when associated to ValidationAttribute attributes. (System.ComponentModel.DataAnnotations.Validator)

/cl[+]
Generate Clone method (shallow copy)
/cl-
Do not generate Clone method (default)

/ap[+]
Enable automatic properties
/ap[-]
Disable automatic properties (default)

/attx[attributeToExclude] <Attribute1,Attribute2>
Comma-separated of property attributes to exclude
(E.g "System.Xml.Serialization.XmlTypeAttribute")

/gpsa
Generate property name specified (All)

/gpsn
Generate property name specified (None)

/gpsd
Generate property name specified (default)

/pfnu
private field name start with Underscore

/pfnf
private field name end with Field

/pfnc
private field name start with custom prefix

/pfncp
Custom prefix for private field name

/cnpr
Custom prefix for class name

/cnsu
Custom suffix for class name

/tc[+]
Enable tacking changes
/tc-
Do not enable tracking changes (default)

/tcc[+]
Enable generation of tracking changes classes (default)
/tcc-
Do not enable generation of tracking changes classes

/hp[+]
Hide private fields in IDE

/hp-
Show private fields in IDE (default)

/clean
Cleanup code

/?, /h[elp]
Show this help

Example:
Xsd2Code.exe Employee.xsd CompanyXYZ.Entities.HumanResources Employee.cs /c ObservableCollection /sc /dbg /cl /hp- /cu System.Xml.Linq,System.IO


There is no content with the specified labels