From christian at gsvitec.com Sat Nov 8 06:21:48 2014 From: christian at gsvitec.com (Christian Sell) Date: Sat Nov 8 06:21:52 2014 Subject: [xsde-users] invalid #include statements in generated code Message-ID: <1313424299.1468849.1415445708764.JavaMail.open-xchange@patina.store> Hello, we have a model that consists of 4 schema files, with the following dependencies viewmodel.xsd |---------import----------> vmf.xsd | | | import | | | V |---------import----------> amf.xsd A | odb.xsd-------import-----------| vmf references a type from amf which is extended in odb, using a substitution group. now when I generate the C++ code with the following call: xsde cxx-hybrid --output-dir gen --generate-parser --generate-aggregate --generate-polymorphic --generate-serializer --no-long-long schema/viewmodel.xsd schema/vmf.xsd schema/amf.xsd schema/odb.xsd I get code that has include statements of the following form #include "schema/odb_xx.h" These include statements are wrong, because all generated code resides in the same subdirectory, namely gen. They also only occur for the odb schema; all other includes are OK. After removing the obsolete "schema/" path from the statements, the code compiles and works. What is going wrong? thanks, Christian From boris at codesynthesis.com Mon Nov 10 04:50:27 2014 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon Nov 10 04:57:52 2014 Subject: [xsde-users] invalid #include statements in generated code In-Reply-To: <1313424299.1468849.1415445708764.JavaMail.open-xchange@patina.store> References: <1313424299.1468849.1415445708764.JavaMail.open-xchange@patina.store> Message-ID: Hi Christian, Christian Sell writes: > xsde cxx-hybrid --output-dir gen --generate-parser --generate-aggregate > --generate-polymorphic --generate-serializer --no-long-long schema/viewmodel.xsd > schema/vmf.xsd schema/amf.xsd schema/odb.xsd > > I get code that has include statements of the following form > > #include "schema/odb_xx.h" You get this schema/ prefix because the corresponding import directive also contains this prefix (e.g., it looks something like "schema/odb.xsd"). By default XSD/e keeps these prefixes since that would make everything work out of the box for multi-directory schemas if the code is generated next to the schemas. Sometimes, however, this is not what the user wants and for such cases there is the --include-regex option that allows you to transform the include directives in any way you want. The example in the manual does pretty much exactly what you would want: http://www.codesynthesis.com/projects/xsde/documentation/xsde.xhtml Boris From christian at gsvitec.com Mon Nov 10 11:04:21 2014 From: christian at gsvitec.com (Christian Sell) Date: Mon Nov 10 11:04:09 2014 Subject: AW: [xsde-users] invalid #include statements in generated code In-Reply-To: References: <1313424299.1468849.1415445708764.JavaMail.open-xchange@patina.store> Message-ID: <000e01cffcff$fd7ad7a0$f87086e0$@gsvitec.com> There is no import directive like you mention. In fact, there isn't even a schema that imports odb.xsd at all (odb imports amf, as shown in my "diagram"). Again: viewmodel.xsd: import "vmf.xsd" import "amf.xsd" vmf.xsd: import "amf.xsd" odb.xsd: import "amf.xsd" I tried to call xsde separately for odb.xsd, which avoids the invalid #include. However, the resulting parser is then not able to detect types defined in odb.xsd, even though they are derived from a type defined in in amf.xsd (and part of a substitutionGroup). Am I making sense? Thanks, Christian -----Urspr?ngliche Nachricht----- Von: Boris Kolpackov [mailto:boris@codesynthesis.com] Gesendet: Montag, 10. November 2014 10:50 An: Christian Sell Cc: xsde-users@codesynthesis.com Betreff: Re: [xsde-users] invalid #include statements in generated code Hi Christian, Christian Sell writes: > xsde cxx-hybrid --output-dir gen --generate-parser > --generate-aggregate --generate-polymorphic --generate-serializer > --no-long-long schema/viewmodel.xsd schema/vmf.xsd schema/amf.xsd > schema/odb.xsd > > I get code that has include statements of the following form > > #include "schema/odb_xx.h" You get this schema/ prefix because the corresponding import directive also contains this prefix (e.g., it looks something like "schema/odb.xsd"). By default XSD/e keeps these prefixes since that would make everything work out of the box for multi-directory schemas if the code is generated next to the schemas. Sometimes, however, this is not what the user wants and for such cases there is the --include-regex option that allows you to transform the include directives in any way you want. The example in the manual does pretty much exactly what you would want: http://www.codesynthesis.com/projects/xsde/documentation/xsde.xhtml Boris From boris at codesynthesis.com Tue Nov 11 04:26:06 2014 From: boris at codesynthesis.com (Boris Kolpackov) Date: Tue Nov 11 04:33:31 2014 Subject: [xsde-users] invalid #include statements in generated code In-Reply-To: <000e01cffcff$fd7ad7a0$f87086e0$@gsvitec.com> References: <1313424299.1468849.1415445708764.JavaMail.open-xchange@patina.store> <000e01cffcff$fd7ad7a0$f87086e0$@gsvitec.com> Message-ID: Hi Christian, Christian Sell writes: > Here they are. I also added the xsdse options file that now fixes the issue > as far as I am concerned, using the import-regex directive as you suggested Thanks for the schemas. I've managed to reproduce this and figure out what's going on. Why the odb-*.hxx include ends up in the generated files is described in detail in the second part of Section 3.7, "Support for Polymorphism": http://codesynthesis.com/projects/xsde/documentation/cxx/hybrid/guide/#3.7 Essentially, it has to be included into the header that defines the aggregates in order to have the derived type parser available. The reason why you end up with the schema/ prefix is the same as with import -- XSD/e by default keeps the prefix that you have supplied. So in this case using the --include-regex option is the right solution. Boris