[xsd-users] Split generated hxx into smaller ones

Boris Kolpackov boris at codesynthesis.com
Wed Feb 5 08:00:10 EST 2020


Antoine Villeret <antoine.villeret at gmail.com> writes:

> xsdcxx cxx-tree  --std c++11 --output-dir ${DEST_DIR}/common
>  --generate-serialization --generate-any-type
> ./schemas_2_1/common/UBL-CommonAggregateComponents-2.1.xsd
> 
> I'm wondering if there is a way to split this header into smaller files to
> make code navigation faster ?

As Benhard has suggested, one option would be to use the file-per-type
mode (--file-per-type). This will cause the generation of a separate
header file for each schema type. While this will most likely solve
your problem, for a large schema this can result in thousands of header
files which poses its own problems.

Another approach would be to try to minimize the amount of unneeded code.
XSD normally issues warning when this could be happening. The most
common culprit are the global elements that are not actually valid
document roots. You can suppress generating parsing/serialization code
for such elements using the --root-element* option. See the XSD compiler
command line manual for details:

https://codesynthesis.com/projects/xsd/documentation/xsd.xhtml



More information about the xsd-users mailing list