Skip to content

# Introduction

The code generator works with:

- XML Schemas v1.0 & v1.1
- WSDL v1.1 definitions with SOAP v1.1 bindings
- DTD external definitions
- Directly from XML and JSON Documents

The xsdata.codegen.transformer will detect and switch parsers based on the resource extension otherwise it will do some heuristic content searches. Before you start make sure the cli requirements are installed.

    $ pip install xsdata[cli]

## Command Line Tool

    $ xsdata generate --help
    ========= xsdata v26.2 / Python 3.14.5 / Platform linux =========

    Usage: xsdata generate [OPTIONS] SOURCE

      Generate code from xsd, dtd, wsdl, xml and json files.

      The input source can be either a filepath, uri or a directory containing
      xml, json, xsd and wsdl files.

    Options:
      -r, --recursive                 Search files recursively in the source
                                      directory
      -c, --config TEXT               Project configuration
      --cache                         Cache sources loading
      --debug                         Show debug messages
      --extensions TEXT               Comma-separated list of extensions to filter
      -p, --package TEXT              Target package [default: generated]
      -o, --output [dataclasses]      Output format name [default: dataclasses]
      --repr / --no-repr              Generate __repr__ method [default: True]
      --eq / --no-eq                  Generate __eq__ method [default: True]
      --order / --no-order            Generate __lt__, __le__, __gt__, and __ge__
                                      methods [default: False]
      --unsafe-hash / --no-unsafe-hash
                                      Generate __hash__ method [default: False]
      --frozen / --no-frozen          Enable read only properties [default: False]
      --slots / --no-slots            Enable __slots__ [default: False]
      -ss, --structure-style [filenames|namespaces|clusters|single-package|namespace-clusters]
                                      Output structure style [default: filenames]
      -ds, --docstring-style [reStructuredText|NumPy|Google|Accessible|Blank]
                                      Docstring style [default: reStructuredText]
      --relative-imports / --no-relative-imports
                                      Use relative imports [default: False]
      --compound-fields / --no-compound-fields
                                      Use compound fields for repeatable elements
                                      [default: False]
      --wrapper-fields / --no-wrapper-fields
                                      Generate wrapper fields [default: False]
      -mll, --max-line-length INTEGER
                                      Adjust the maximum line length [default: 79]
      --generic-collections / --no-generic-collections
                                      Use generic collections (Iterable, Mapping)
                                      [default: False]
      --unnest-classes / --no-unnest-classes
                                      Move inner classes to upper level [default:
                                      False]
      --ignore-patterns / --no-ignore-patterns
                                      Ignore pattern restrictions [default: False]
      --include-header / --no-include-header
                                      Include a header with codegen information in
                                      the output [default: False]
      --help                          Show this message and exit.

## Use a directory as source

You can instruct the cli to search all subdirectories recursively with the `-r, --recursive` flag.

    $ xsdata generate project/schemas
    $ xsdata generate project/schemas --recursive

## Use a filename or URI as source

    $ xsdata generate project/schemas/feed.xsd
    $ xsdata generate http://www.gstatic.com/localfeed/local_feed.xsd