From Code Synthesis Wiki
For the release of XSD 2.3.0 we've fixed the part of the Xerces-C++ bug 1281 that prevented Xerces-C++ schema validator from accepting the GML 3.1.1 schemas. All precompiled binaries of XSD from version 2.3.0 are shipped with this fix. Note that you don't need to patch the version of Xerces-C++ that you are linking to your applications since the bug only affects the validation of schemas (as opposed to the validation of instances against schemas) which is normally disabled. Note also that this bug has been fixed in Xerces-C++ 2.8.0.
While with this patch XSD is able to parse GML 3.1.1 successfully, it is still unable to generate compilable C++ code in the default, file-per-schema mode due to a pathological circular dependency between smil20.xsd and smil20-language.xsd. There are two ways to resolve this issue.
The first approach requires the use of the file-per-type compilation mode which was introduced in XSD 3.1.0. For more information about the file-per-type mode see this blog post.
The second approach involves splitting smil20.xsd into two files. The resulting schemas are semantically equivalent to the original.
The following two packages contain the official GML 3.1.1 schemas placed into a single directory with the smil20.xsd schema split into smil20.xsd and smil20-base.xsd:
We used the following C++/Tree options to compile GML 3.1.1:
--generate-polymorphic --polymorphic-type-all --root-element Array --root-element Bag
For ideas on how to handle very large GML documents using the C++/Tree mapping, see the CityGML 1.0.0 and C++/Parser interface thread on the xsd-users mailing list as well as the
streaming example in the XSD distribution.
Brad Howes has posted a well commented CMakeLists.txt file that compiles the unmodified GML 3.1.1 schemas and builds a dynamic library from the GML C++ classes using CMake. For general information on XSD and CMake, see the Using XSD with CMake page.
The GML 3.2.0 schemas can only be compiled in the file-per-type mode. The following two packages contain sample Makefiles, XSD options files, and README files that show how to compile these schemas using XSD. The first package writes all the generated files into a single directory (that is, it flattens the directory hierarchy) while the second package shows how to place the generated files into separate sub-directories.