The XBinder distribution contains a command-line compiler executable as well as a graphical user interface (GUI) wizard that can aid in the specification of compiler options. This section describes how to run the command-line version; the operation of the GUI is described in the online help files built into the wizard.
To test if XBinder was successfully installed, enter xbinder with no parameters as follows (note: if you have not updated your PATH variable, you will need to enter the full pathname):
xbinder
You should observe the following display (or something similar):
XBinder Compiler, Version 2.6.0 Copyright (c) 2002-2018 Objective Systems, Inc. All Rights Reserved. Usage: xbinder <filename> options <filename> XML schema or WSDL source file name(s). Multiple filenames may be specified. * and ? wildcards are allowed. Language options (choose only one): -c Generate C code -c++ or -cpp Generate C++ code -c# or -csharp Generate C# code -java Generate Java code Basic options: -xml Generate XML encode/decode functions -config <file> Specify schema bindings file. -o <directory> Output file directory -I <directory> Import file directory -all Compile all dependent files -warnings Output compiler warning messages -compat <version> Generate code compatible with previous compiler version. <version> format is x.x (for example, 1.0) Options to reduce amount of generated code: -lax Generate code that does lax error checking -noderiv Do not generate special derived type code Options to alter generated code: -namespace Specify a namespace prefix for all generated items -nodatestamp Do not put date stamp in header -nomixed Do not generate string structure for mixed content -elemCasing <value> Set element name case to lower/upper -typeCasing <value> Set type name case to lower/upper Options for the generation of additional code: -genPrint or -print Generate print functions C/C++ basic options: -dom Generate DOM encode/decode functions (C only) -json Generate JSON encode/decode functions (C only) -sax Generate SAX-based decoders (default is pull-parser) -modularize Handle included schemas as separate modules -nodecode Do not generate decode functions -noencode Do not generate encode functions -trace Add trace diag msgs to generated code C/C++ options to reduce amount of generated code: -compact Generate compact code -nocopy Do not generate copy methods (C++ only) -noheader Do not add code to encode XML header (<? xml ...) -noxmlns Do not generate code to support XML namespaces C/C++ options to alter generated code: -borland Generate special code for Borland C++ compiler -c14n Generate C14N format encode functions -cppns <ns> Add given C++ namespace to generated code (C++ only) -cppext <ext> Set file extension for generated C++ source files -derivModel <model> Set the derivation model to extended/interface -enumchoice Generate enum type for type selector for choice types -fragments Generate code to encode XML fragments (start element, contents, end element) -initlists Generate code that initializes lists to default (when possible) -noEncDefault Do not add schema default/fixed values to XML instance -noDefaultNs Do not use default namespace in XML instance -noNamedBits Do not generate named bits for EnumList, use regular list instead -numDateTime Use numeric structures for all date/time types -pdu <element> Designate element to be a PDU -project <prj_name> Set project name -soap, -soap12 Generate code to format/parse SOAP v1.2 messages -soap11 Generate code to format/parse SOAP v1.1 messages -static Generate code that uses static memory (when possible, C only) -strict Generate code that does strict syntax checking -useNSPfx Use XSD namespace prefixes in C/C++ code -useflteq Use float equality functions to ignore rounding errors in floating-point comparisons -use-qt [QList | QLinkedList | QVector | QVarLengthArray] Use Qt classes for strings and lists, using the given Qt collection class as the default for lists. Default is QLinkedList. -usestl Use C++ Standard Template Library (STL) -noenumvars Do not generate fields using generated enum types; revert to prior behavior (generate OSUINT16 instead) -w64 Generate Visual Studio project files for a 64-bit XBinder installation -x64 Generate code using 64-bit integers for lengths on 64-bit systems C/C++ options for the generation of additional code: -getset Generate C++ getters and setters -genWriter Generate writer test program -genReader Generate reader test program -genFree Generate memory free functions (C only) -genFactory Generate Factory functions -genRWTest Generate read/write test program -genStubs Generate SOAP client stub functions from WSDL -genSkel Generate SOAP skeleton server program from WSDL -genClient Generate web service client test program from WSDL -genSSLClient Generate a secure HTTP client test program using OpenSSL -genSSLStubs Generate secure HTTP stub functions using OpenSSL -genTest [<xmlfile>] Generate test code. If XML instance provided, this will be used; otherwise, random data -genValid Generate validation functions -usePDU <element> Use PDU for writer/reader test program -w32 Use with '-genMake' to generate Windows NMAKE file (default = GNU) C/C++ options for makefile or project generation: -genMake Generate makefile -genMakeLib [<libname>] Generate code in makefile to put all objects into a static library -genMakeDLL [<dllname>] Generate code in makefile to build shared object -genvcproj [version] Generate Visual Studio C/C++ project files [version] is 2017, 2015, 2013, 2012, 2010, 2008, 2005, 2003, vc6 (Windows only) -makeopts <dynamiclib | staticlib | multithreaded> Use compilation options for dynamic, static, and multithreaded libraries. C/C++ compression options: -zip Add code to generated reader/writer to use standard gzip compression (requires zlib install) C# extra options: -csfile <name> Specifies one .cs file for all generated code Set <name> to '*.cs' for one .cs file per .xsd file -csnsname <name> Name for C# namespace -csnspfx <prefix> C# namespace names will be this prefix, followed by schema name -genMake Generate makefile -genWriter Generate writer test program -genReader Generate reader test program -genvcproj <version> Generate Visual Studio C# project files <version> is 2017, 2015, 2013, 2012, 2010, 2008, 2005 (Windows only) -nocsgetset Generate properties only, no getter/setter methods -usePDU <element> Use PDU for writer/reader test program Java extra options: -pkgname <name> Name for Java package -pkgpfx <prefix> Java package names will be this prefix, followed by schema name -genMake Generate Apache Ant buildfile (build.xml) -genWriter Generate writer test program -genReader Generate reader test program -usePDU <element> Use PDU for writer/reader test program -xpp Use XmlPull API rather than StAX (StAX is default)
To use the compiler, at a minimum, a single XSD source file must be provided along with at least one set of encoding rules and a target output language. The current version of XBinder supports the generation of C (-c option), C++ (-cpp option), C# (-c# or -csharp) and Java (-java) source code. For C# and Java, XBinder supports the generation of code to encode/decode XML (-xml).
The source file specification can be a full pathname or only what is necessary to qualify the file. If directory information is not provided, the user's current default directory is assumed. Multiple source filenames may be specified on the command line to compile a set of files. The wildcard characters ‘*’ and ‘?’ are also allowed in source filenames (for example, the command ‘xbinder *.xsd -c -xml’ will compile all XSD files in the current working directory).
The source file specification can be a full pathname or only what is necessary to qualify the file. If directory information is not provided, the user's current default directory is assumed. Multiple source filenames may be specified on the command line to compile a set of files. The wildcard characters ‘*’ and ‘?’ are also allowed in source filenames (for example, the command ‘xbinder *.xsd -c -xml’ will compile all XSD files in the current working directory).
The following table lists all of the command line options (those relevant to C# or Java) in alphabetical order and what they are used for:
Option | Argument | Description |
---|---|---|
-all | None | Generate code for all dependent files in a given compilation. This includes the main XSD files specified on the command line as well as all imported and included schema files. |
-csfile | *.cs or a specific .cs file name | If valued with *.cs, indicates that XBinder is to generate one .cs file for each .xsd file processed. If valued with a specific .cs file name, indicates that XBinder is to generate one .cs file to hold all code. Do not specify any folder information in the -csfile value; use the -o qualifier instead. |
-c# -csharp | None | Generate C# code |
-compat | <version> | Generate code that is compatible with an older version of the XBinder compiler. The format of the version number is "n.n" (for example, 1.0). As of XBinder 2.0, this has no meaning for C# or Java code generation, but it may be applicable in the future. |
-config | <filename> | This option is used to specify the name of a file containing configuration information for the source file being parsed. This is similar to the ‘binding schema’ used with some other XML data binding applications |
-csnsname | <name> | Provides a C# namespace name. All classes will be generated into this namespace. |
-csnspfx | <prefix> | Provides a prefix for C# namespace names. Each class will be generated into a namespace named <prefix>.<schema>, where <schema> is based on the name of the XSD file from which the class was generated. |
-elemCasing | lower or upper |
This option is used to change the case of the first letter in element names in the generated code from what is specified in the XSD file. This option is typically used when the XSD file contains type, element, and/or attribute names that are the same. It provides a way to disambiguate names in the generated code. Typically, element names are set to lower case. lower is the default for C# and Java See -typeCasing for changing the case of type names. |
-genMake | None |
For C#, XBinder will generate a makefile. For Java, XBinder will generate an Apache Ant buildfile. |
-genPrint | None | Generate print utility functions. Print functions are debug functions that allow the contents of generated type variables to be written to any given output stream. |
-genReader | None | Generate a sample reader program |
-genvcproj | <version> (optional) |
For C# only, XBinder will generate a Visual Studio project file. <version> specifies the version of Visual Studio (2019, 2017, 2015, 2013, 2012, 2010, 2008, or 2005). Not specifying a version will cause the compiler to generate a project for Visual Studio 2015. |
-genWriter | None | Generate a sample writer program |
-I | <directory> | This option is used to specify a directory that will be searched for XSD <import> and <include> items. Multiple –I qualifiers can be used to specify multiple directories to search. |
-lax | None | This option causes decode/validation functions to be generated that contain less schema-validation error checking code. This can be useful for working with XML documents that are not completely valid with regards to the schema. |
-modularize | None | This option is used when XSD <include> directives are included in a schema to tell the processor to put the generated code in separate output files based on the definitions in the included files. The default behavior if this is not used is to include all of the code in the main file that is including the definitions. This can only be used if the included files can be successfully compiled on their own (i.e. are not dependent on definitions from the parent module). |
-namespace | <prefix> | Add the given prefix to all class names. This makes it possible to disambiguate items with the same names that are in different schemas. Note that the -csnspfx (for C#) or -pkgpfx (for Java) can be used to derive C# namespaces or Java package names from the name of the XSD file. |
-nocsgetset | None | Do not generate getter and setter methods for C#. The default behavior, if this option isn't present, is to generate both getter/setter methods and properties. If this option is specified, only properties will be generated. |
-nodatestamp | None | Do not insert a date stamp in the header of each generated file. This can be useful when using a source control system to prevent identical source files from appearing different. |
-noderiv | None | Suppress generation of extra code for run-time derived type handling. This code makes it possible to decode complexContent types using xsi:type declarations. |
-nomixed | None | Do not generate a special structure to hold mixed content items. The generated code will more closely match the schema layout. However, mixed content will not be supported. |
-o | <directory> | This option is used to specify the name of a directory to which all of the generated files will be written. |
-pkgname | <name> | Provides a Java package name. All classes will be generated into this package. |
-pkgpfx | <prefix> | Provides a prefix for package names. Each class will be generated into a package named <prefix>.<schema>, where <schema> is based on the name of the XSD file from which the class was generated. |
None | see -genPrint | |
-typeCasing | lower or upper |
This option is used to change the case of the first letter in generated class names from what is specified in the XSD file. This option is typically used when the XSD file contains type, element, and/or attribute names that are the same. It provides a way to disambiguate the names in the generated code. The default for C# and Java is upper. See -elemCasing for changing the case of element names. |
-usePDU | name of element | When generating sample code (example -genReader -genWriter), this option tells XBinder which global element should be handled by the sample code. |