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.0.x Copyright (c) 2002-2009 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) -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 namespace attributes in all structs C/C++ options to alter generated code: -c14n Generate C14N format encode functions -cppns <ns> Add given C++ namespace to generated code (C++ only) -fragments Generate code to encode XML fragments (start element, contents, end element) -static Generate code that uses static memory (when possible, C only) -initlists Generate code that initializes lists to default (when possible) -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 -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 -usestl Use C++ Standard Template Library (STL) (currently, only STL string type is used) -derivModel <model> Set the derivation model to extended/inteface.
C/C++ options for the generation of additional code: -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 -makeopts <dynamiclib | staticlib | multithreaded> Use compilation options for dynamic, static, and multithreaded libraries. -genWriter Generate writer test program -genReader Generate reader test program -genFree Generate memory free functions (C only) -genKeyTest Generate code to test identity constraints (xsd:key, xsd:keyref, xsd:unique) -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 -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++ compression options: -exicompress Add code to generated reader/writer to use Efficient XML Interchange (EXI) format -zip Add code to generated reader/writer to use standard gzip compression (requires zlib install) C# extra options: -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 -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
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. |
-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. |
-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. |
-genMake | None |
For C#, XBinder will generate a makefile. For Java, XBinder will generate an Apache Ant buildfile. |
-genReader | None | Generate a sample reader program |
-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. |
-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. |