# NAME

xsd - W3C XML Schema Definition Compiler

# SYNOPSIS

`xsd command [options] file ...`
`xsd help [command]`
`xsd version`

# DESCRIPTION

`xsd` generates vocabulary-specific statically-typed C++ mapping from W3C XML Schema definitions. Particular mapping to produce is selected by a `command`. Each mapping has a number of mapping-specific `options` that should appear, if any, after the `command`. Input files should be W3C XML Schema definitions. For each input file in the form `name.xsd` at least two C++ files are generated: `name.hxx` and `name.cxx`. Optionally, inline file, `name.ixx`, can also be generated.

# COMMANDS

`cxx-tree`
  Generate C++ tree mapping.
`help`
  Print usage information and exit. Use

  `xsd help command`

  for command-specific help.
`version`
  Print version and exit.

# OPTIONS

Command-specific `options`, if any, should appear after the corresponding `command`.

## cxx-tree command options

`--char-type type`
  Generate code using the provided character `type` instead of the default `char`. Valid values are `char` and `wchar_t`.
`--output-dir dir`
  Write generated files to `dir` instead of the current directory.
`--generate-inline`
  Generate simple functions inline. This option triggers creation of the inline file.
`--generate-ostream`
  Generate ostream insertion operators (`operator<<`) for generated types.
`--namespace-regex regex`
  Add `regex` to the list of regular expressions used to translate W3C XML Schema namespace names to C++ namespace names. `regex` is a perl-like regular expression in the form `/pattern/replacement/`. Any character can be used as a delimiter instead of `/`. Escaping of the delimiter character in `pattern` or `replacement` is not supported.

  All regular expressions are pushed into a stack with the last specified expression considered first. The first match that succeeds is used. Regular expressions are applied to a string of the form

  `filename namespace`

  For example,

  `XMLSchema.xsd http://www.w3.org/2001/XMLSchema`

  The `filename` for the current translation unit is empty. For example, if you have file `hello.xsd` with namespace `http://hello.com/hello` and you run `xsd` on this file then the string in question would be:

  `http://hello.com/hello`

  Note the leading space.

  The following three steps are performed for each regular expression until the match is found:

  1. The expression is applied and if the result is empty the next expression is considered.
  2. All `/` are replaced with `::`.
  3. The result is verified to be a valid C++ scope name (e.g., `foo::bar`). If this test succeeds, the result is used as a C++ namespace name.

  As an example, the following expression maps XML Schema namespaces in the form `http://www.acme.com/xmlns/foo/bar` to C++ namespaces in the form `acme::foo::bar`:

  `%.* http://www.acme.com/xmlns/(.+)%acme::$1%`

`--hxx-suffix suffix`
  Use the provided `suffix` instead of the default `.hxx` to construct the name of the header file. Note that this suffix is also used to construct names for included/imported schemas.
`--ixx-suffix suffix`
  Use the provided `suffix` instead of the default `.ixx` to construct the name of the inline file.
`--cxx-suffix suffix`
  Use the provided `suffix` instead of the default `.cxx` to construct the name of the source file.
`--hxx-regex regex`
  Use the provided expression to construct the name of the header file. `regex` is a perl-like regular expression in the form `/pattern/replacement/`. Note that this expression is also used to construct names for included/imported schemas.
`--ixx-regex regex`
  Use the provided expression to construct the name of the inline file. `regex` is a perl-like regular expression in the form `/pattern/replacement/`.
`--cxx-regex regex`
  Use the provided expression to construct the name of the source file. `regex` is a perl-like regular expression in the form `/pattern/replacement/`.
`--hxx-prologue text`
  Insert `text` at the beginning of the header file.
`--ixx-prologue text`
  Insert `text` at the beginning of the inline file.
`--cxx-prologue text`
  Insert `text` at the beginning of the source file.
`--prologue text`
  Insert `text` at the beginning of each generated file for which there is no file-specific prologue.
`--hxx-epilogue text`
  Insert `text` at the end of the header file.
`--ixx-epilogue text`
  Insert `text` at the end of the inline file.
`--cxx-epilogue text`
  Insert `text` at the end of the source file.
`--epilogue text`
  Insert `text` at the end of each generated file for which there is no file-specific epilogue.
`--hxx-prologue-file file`
  Insert the content of the `file` at the beginning of the header file.
`--ixx-prologue-file file`
  Insert the content of the `file` at the beginning of the inline file.
`--cxx-prologue-file file`
  Insert the content of the `file` at the beginning of the source file.
`--prologue-file file`
  Insert the content of the `file` at the beginning of each generated file for which there is no file-specific prologue file.
`--hxx-epilogue-file file`
  Insert the content of the `file` at the end of the header file.
`--ixx-epilogue-file file`
  Insert the content of the `file` at the end of the inline file.
`--cxx-epilogue-file file`
  Insert the content of the `file` at the end of the source file.
`--epilogue-file file`
  Insert the content of the `file` at the end of each generated file for which there is no file-specific epilogue file.
`--export-symbol symbol`
  Insert `symbol` in places where Win32 DLL export/import control statements (`__declspec(dllexport/dllimport)`) are necessary.
`--show-sloc`
  Show the number of generated physical source lines of code (SLOC).

# DIAGNOSTICS

If the input file is not a valid W3C XML Schema definition, `xsd` will issue diagnostic messages to STDERR and exit with non-zero exit code.

# BUGS

Send bug reports to the xsd-users@codesynthesis.com mailing list.