Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
40a9c7e
Include element name in inline element error message
mcraveiro Aug 1, 2026
92d6b8b
Handle references to abstract elements in XSD
mcraveiro Aug 1, 2026
fc7a2ed
Handle elements without type definitions
mcraveiro Aug 1, 2026
a449982
Merge pull request #19 from craflin/abstract-refs
craflin Aug 1, 2026
a346b18
Fix code generation for complex XSD schemas
mcraveiro Aug 1, 2026
c308014
Merge pull request #20 from craflin/enums-and-simple-ref
craflin Aug 1, 2026
e427be4
Add ORE XSD test suite
mcraveiro Aug 1, 2026
b4e3575
Fix duplicate elements and add vector<bool> safety
mcraveiro Aug 1, 2026
82335de
Fix Ore_test to use enum values for TradeType comparison
mcraveiro Aug 1, 2026
09af66e
Add command line options for separate output dirs and wrap namespace
mcraveiro Aug 1, 2026
a071125
Add --no-inner-namespace option to skip inner namespace generation
mcraveiro Aug 1, 2026
887660f
Document command line options in README
mcraveiro Aug 1, 2026
68baae1
Add XML save/serialize functionality
mcraveiro Aug 1, 2026
2d280f1
Add include-prefix option and update README with save functions
mcraveiro Aug 1, 2026
773707f
Add support for group refs, substitution groups, and fix unbounded in…
mcraveiro Aug 1, 2026
de691ca
Fix abstract element refs (substitution groups) being silently dropped
mcraveiro Aug 1, 2026
b0fef6d
Fix xs:any for complex types, add CDATA support, and fix choice group…
mcraveiro Aug 1, 2026
bf2b363
Fix xs:union types generating { 0, nullptr } ElementInfo (missing Rea…
mcraveiro Aug 1, 2026
0e58534
Add xs:any child element capture via other_elements field
mcraveiro Aug 1, 2026
1146c4d
Value-initialise mandatory struct fields to fix uninitialised member UB
mcraveiro Aug 1, 2026
a4f39f4
[xsd] Fix vector<T> to use alias instead of inheritance for non-bool …
mcraveiro Aug 1, 2026
e18d68d
[xsd] Add missing operator= to bool_vector
mcraveiro Aug 1, 2026
0489751
[xsd] Fix vector<T> incomplete type failure on GCC/Clang + libstdc++ 15
mcraveiro Aug 1, 2026
bb69d60
[xsd] Restore <cstdint> include dropped during vector<T> rewrite
mcraveiro Aug 1, 2026
5feaf44
[xsd] Fix copy-assignment exception safety and moved-from null deref
mcraveiro Aug 1, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 48 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ XSDCPP solves the issue by creating a data model and parser that can easily be a

## Features and Limitations

Since XSD is full of features (and unnecessary complexity), it's very hard to support all of them.
Since XSD is full of features (and unnecessary complexity), it's very hard to support all of them.
So, XSDCPP does currently just support what was thrown at it so far and there are probably some severe limitations.

Notable supported features:
Expand Down Expand Up @@ -61,6 +61,47 @@ Intentionally not supported features:
* Initialize submodules. `cd xsdcpp && git submodule update --init`
* Build the project using CMake (`mkdir build && cd build && cmake .. && cmake --build .`) or Conan (`conan build .`).

## Command Line Options

```
xsdcpp [<xsd-file>] [options]
```

| Option | Description |
|-------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `-o <dir>`, `--output=<dir>` | The folder in which the output files are created. |
| `-H <dir>`, `--header-output=<dir>` | The folder in which the header files (.hpp) are created. Overrides `-o` for header files. |
| `-C <dir>`, `--cpp-output=<dir>` | The folder in which the implementation files (.cpp) are created. Overrides `-o` for implementation files. |
| `-n <name>`, `--name=<name>` | The namespace used for the generated data model and base name of the output files. The default is derived from the XSD filename. |
| `-w <ns>`, `--wrap-namespace=<ns>` | Wrap all generated code in an additional C++ namespace. Supports nested namespaces using `::` syntax (e.g., `a::b::c`). |
| `-P <prefix>`, `--include-prefix=<prefix>` | Prefix for `#include` directives in generated `.cpp` files. Use when headers are in a different directory structure than sources. |
| `-e <ns>`, `--extern=<ns>` | A namespace that should not be generated in the output files and hence must be provided separately. Use this to avoid code duplication if you have a schema that is the base for multiple other schemas. Set to `xsdcpp` to omit the generation of the core parser library. |
| `-t <type>`, `--type=<type>` | Enforce the generation of a type that is not directly referenced from a root element. Can be specified multiple times. |

### Examples

Basic usage:
```
xsdcpp Example.xsd -o /your/output/folder
```

Separate header and implementation directories:
```
xsdcpp Example.xsd -H include/ -C src/
```

Wrap generated code in a namespace:
```
xsdcpp Example.xsd -o out/ -w myproject::xml
```
This generates types like `myproject::xml::Example::Person`.

Rename the inner namespace and wrap in an outer namespace:
```
xsdcpp Example.xsd -o out/ -w myproject::xml -n types
```
This generates types like `myproject::xml::types::Person`.

## Example

An XSD schema *Example.xsd* like this:
Expand Down Expand Up @@ -160,10 +201,12 @@ struct Country : xsd::base<Example::CountryCode>

}
```
And functions to load an XML file or XML data from a string:
And functions to load and save XML:
```cpp
void load_file(const std::string& file, List& List);
void load_data(const std::string& data, List& List);
void load_file(const std::string& file, List& list);
void load_data(const std::string& data, List& list);
void save_file(const std::string& file, const List& list);
std::string save_data(const List& list);
```
(The implementation of these functions can be found in *Example.cpp* and *Example_xsd.hpp* provides the types of the *xsd* namespace.)

Expand Down Expand Up @@ -197,4 +240,4 @@ int main()
return 0;
}
```
The generated functions will validate the input data to some degree and throw exceptions for missing or unknown elements or attributes etc..
The generated functions will validate the input data to some degree and throw exceptions for missing or unknown elements or attributes etc..
4 changes: 2 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ add_subdirectory(ResourceCompiler)

add_custom_command(
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/Resources.hpp"
COMMAND ResourceCompiler "${CMAKE_CURRENT_SOURCE_DIR}/xsd.hpp" "${CMAKE_CURRENT_SOURCE_DIR}/XmlParser.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/XmlParser.hpp" -o "${CMAKE_CURRENT_BINARY_DIR}/Resources.hpp"
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/xsd.hpp" "${CMAKE_CURRENT_SOURCE_DIR}/XmlParser.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/XmlParser.hpp" "$<TARGET_FILE:ResourceCompiler>"
COMMAND ResourceCompiler "${CMAKE_CURRENT_SOURCE_DIR}/xsd.hpp" "${CMAKE_CURRENT_SOURCE_DIR}/XmlParser.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/XmlParser.hpp" "${CMAKE_CURRENT_SOURCE_DIR}/XmlWriter.hpp" "${CMAKE_CURRENT_SOURCE_DIR}/XmlWriter.cpp" -o "${CMAKE_CURRENT_BINARY_DIR}/Resources.hpp"
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/xsd.hpp" "${CMAKE_CURRENT_SOURCE_DIR}/XmlParser.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/XmlParser.hpp" "${CMAKE_CURRENT_SOURCE_DIR}/XmlWriter.hpp" "${CMAKE_CURRENT_SOURCE_DIR}/XmlWriter.cpp" "$<TARGET_FILE:ResourceCompiler>"
)

add_library(libxsdcpp STATIC
Expand Down
Loading
Loading