XSD/Schema compilation checklist

From Code Synthesis Wiki

(Difference between revisions)
Jump to: navigation, search
Revision as of 10:59, 17 February 2008
Boris (Talk | contribs)

← Previous diff
Revision as of 12:13, 17 February 2008
Boris (Talk | contribs)

Next diff →
Line 1: Line 1:
-This page provides a checklist-like run through the most commonly used XSD options. For more details on each option as well as for the complete list of options refer to the [http://www.codesynthesis.com/projects/xsd/documentation/xsd.xhtml XSD command line interface documentation (man pages)].+This page provides a checklist-like run through the most commonly used XSD command line options. For more details on each option as well as for the complete list of options refer to the [http://www.codesynthesis.com/projects/xsd/documentation/xsd.xhtml XSD command line interface documentation (man pages)].
__TOC__ __TOC__
Line 7: Line 7:
The following options are available for all mappings: The following options are available for all mappings:
-* You can map any XML Schema namespace (including the no-namespace case and built-in XML Schema namespace) to a custom C++ namespace with the <code>--namespace-map</code> option, for example, <code>--namespace-map http://www.example.com/xmlns/my=Example::My</code>. To place the generated code for a schema without a target namespace into a C++ namespace, use the empty string as XML Schema namespace: <code>--namespace-map =My</code>. To map a set of namespaces at once the <code>--namespace-regex</code> option is available.+* You can map any XML Schema namespace (including the no-namespace case and built-in XML Schema namespace) to a custom C++ namespace with the <code>--namespace-map</code> option, for example, <code>--namespace-map http://www.example.com/xmlns/my=Example::My</code>. To place the generated code for a schema without a target namespace into a C++ namespace, use the empty string as XML Schema namespace: <code>--namespace-map =My</code>. To map a set of namespaces at once the <code>--namespace-regex</code> option can be used.
* To place the generated code into a specific directory, use the <code>--output-dir</code> options, for example, <code>--output-dir src</code>. * To place the generated code into a specific directory, use the <code>--output-dir</code> options, for example, <code>--output-dir src</code>.
Line 13: Line 13:
* You can select the character type that should be used in the generated code with the <code>--char-type</code> option. Available choices are <code>char</code> (default), and <code>wchar_t</code>. For more information see [http://www.codesynthesis.com/projects/xsd/documentation/cxx/tree/guide/#3.1 Section 3.1, "Character Type"] in the [http://www.codesynthesis.com/projects/xsd/documentation/cxx/tree/guide/ C++/Tree Mapping Getting Started Guide] and [http://www.codesynthesis.com/projects/xsd/documentation/cxx/parser/guide/#5.1 Section 5.1, "Character Type"] in the [http://www.codesynthesis.com/projects/xsd/documentation/cxx/parser/guide/ C++/Parser Mapping Getting Started Guide]. * You can select the character type that should be used in the generated code with the <code>--char-type</code> option. Available choices are <code>char</code> (default), and <code>wchar_t</code>. For more information see [http://www.codesynthesis.com/projects/xsd/documentation/cxx/tree/guide/#3.1 Section 3.1, "Character Type"] in the [http://www.codesynthesis.com/projects/xsd/documentation/cxx/tree/guide/ C++/Tree Mapping Getting Started Guide] and [http://www.codesynthesis.com/projects/xsd/documentation/cxx/parser/guide/#5.1 Section 5.1, "Character Type"] in the [http://www.codesynthesis.com/projects/xsd/documentation/cxx/parser/guide/ C++/Parser Mapping Getting Started Guide].
-* If you have several schema files and some of them are not self-sufficient (that is, you get XML Schema errors when trying to compile them with XSD) or have cyclic dependecies that involve inheritance (that is, you get C++ errors when compiling the generated code with the message saying that the base type is undefined) then you will need to use the file-per-type compilation mode which is turned on with the <code>--file-per-type</code> option. For more information about the file-per-type mode see this [http://www.codesynthesis.com/~boris/blog/2008/02/13/codesynthesis-xsd-3-1-0-released/ blog post].+* If you have several schema files and some of them are not self-sufficient (that is, you get XML Schema errors when trying to compile them separately with XSD) or have cyclic dependecies that involve inheritance (that is, you get a C++ error when compiling the generated code with the message saying that the base type is undefined) then you will need to use the file-per-type compilation mode which is turned on with the <code>--file-per-type</code> option. For more information about the file-per-type mode see this [http://www.codesynthesis.com/~boris/blog/2008/02/13/codesynthesis-xsd-3-1-0-released/ blog post].
== C++/Tree Mapping Options == == C++/Tree Mapping Options ==
Line 19: Line 19:
The following options are specific to the [[Tree|C++/Tree mapping]]: The following options are specific to the [[Tree|C++/Tree mapping]]:
-* If you are planning to serialize the object model back to XML, then use the <code>--generate-serialization</code> option. See [http://www.codesynthesis.com/projects/xsd/documentation/cxx/tree/guide/#6 Chapter 6, "Serialization"] in the [http://www.codesynthesis.com/projects/xsd/documentation/cxx/tree/guide/ C++/Tree Mapping Getting Started Guide] for details.+* If you are planning to serialize the object model back to XML, then you will need to specify the <code>--generate-serialization</code> option. See [http://www.codesynthesis.com/projects/xsd/documentation/cxx/tree/guide/#6 Chapter 6, "Serialization"] in the [http://www.codesynthesis.com/projects/xsd/documentation/cxx/tree/guide/ C++/Tree Mapping Getting Started Guide] for details.
* If your schema defines several global elements while only some of them can be used as document root elements, then use the <code>--root-element</code> option to reduce the amount of the generated code, for example, <code>--root-element library</code>. * If your schema defines several global elements while only some of them can be used as document root elements, then use the <code>--root-element</code> option to reduce the amount of the generated code, for example, <code>--root-element library</code>.
Line 29: Line 29:
* If your XML vocabulary uses XML Schema wildcards (<code>xsd:any</code> and <code>xsd:anyAttribute</code>) then you may want to use the <code>--generate-wildcard</code> option. See [http://www.codesynthesis.com/projects/xsd/documentation/cxx/tree/manual/#2.12 Section 2.12, "Mapping for any and anyAttribute"] in the [http://www.codesynthesis.com/projects/xsd/documentation/cxx/tree/manual/ C++/Tree Mapping User Manual] for details. * If your XML vocabulary uses XML Schema wildcards (<code>xsd:any</code> and <code>xsd:anyAttribute</code>) then you may want to use the <code>--generate-wildcard</code> option. See [http://www.codesynthesis.com/projects/xsd/documentation/cxx/tree/manual/#2.12 Section 2.12, "Mapping for any and anyAttribute"] in the [http://www.codesynthesis.com/projects/xsd/documentation/cxx/tree/manual/ C++/Tree Mapping User Manual] for details.
-* If you are using Visual Studio 2005 and rely on IntelliSense, then you may want to compile your schemas with the <code>--generate-intellisense</code> option.+* If you are using Visual Studio 2005 (8.0) and rely on IntelliSense, then you may want to compile your schemas with the <code>--generate-intellisense</code> option. This option is not needed if you are using Visual Studion 2008 (9.0).
-* If your schema is large and the resulting C++ source file is too big for the C++ compiler to handle (for example, the C++ compiler runs out of memory), then you can use the <code>--parts</code> option to split this file into several smaller files, for example, <code>--parts 4</code>. The file-per-type compilation mode discussed above can also be used to address this issue.+* If your schema is large and the resulting C++ source file is too big for the C++ compiler to handle (for example, the C++ compiler runs out of memory), then you can use the <code>--parts</code> option to split this file into several files, for example, <code>--parts 4</code>. The file-per-type compilation mode discussed above can also be used to address this issue.
== C++/Parser Mapping Options == == C++/Parser Mapping Options ==
Line 41: Line 41:
* If your XML vocabulary uses XML Schema polymorphism (<code>xsi:type</code> or substitution groups), then you will need to compile your schemas with the <code>--generate-polymorphic</code> option. See [http://www.codesynthesis.com/projects/xsd/documentation/cxx/parser/guide/#5.4 Section 5.4, "Support for Polymorphism"] in the [http://www.codesynthesis.com/projects/xsd/documentation/cxx/parser/guide/ C++/Parser Mapping Getting Started Guide] for details. * If your XML vocabulary uses XML Schema polymorphism (<code>xsi:type</code> or substitution groups), then you will need to compile your schemas with the <code>--generate-polymorphic</code> option. See [http://www.codesynthesis.com/projects/xsd/documentation/cxx/parser/guide/#5.4 Section 5.4, "Support for Polymorphism"] in the [http://www.codesynthesis.com/projects/xsd/documentation/cxx/parser/guide/ C++/Parser Mapping Getting Started Guide] for details.
-* You can request and suppress generation of the validation code with the <code>--generate-validation</code> and <code>--suppress-validation</code> options, respectively. By default, validation code is generated when non-validating underlying XML parser is used (Expat) and suppressed otherwise. See [http://www.codesynthesis.com/projects/xsd/documentation/cxx/parser/guide/#5.5 Section 5.5, "XML Schema Validation"] in the [http://www.codesynthesis.com/projects/xsd/documentation/cxx/parser/guide/ C++/Parser Mapping Getting Started Guide] for details.+* You can request and suppress generation of the validation code with the <code>--generate-validation</code> and <code>--suppress-validation</code> options, respectively. By default, validation code is generated when a non-validating underlying XML parser is used (Expat) and suppressed otherwise (Xerces-C++). See [http://www.codesynthesis.com/projects/xsd/documentation/cxx/parser/guide/#5.5 Section 5.5, "XML Schema Validation"] in the [http://www.codesynthesis.com/projects/xsd/documentation/cxx/parser/guide/ C++/Parser Mapping Getting Started Guide] for details.
* You can request generation of sample parser implementations with the <code>--generate-noop-impl</code> (generates empty implementations) and <code>--generate-print-impl</code> (generates implementations that print the data stored in XML) options. * You can request generation of sample parser implementations with the <code>--generate-noop-impl</code> (generates empty implementations) and <code>--generate-print-impl</code> (generates implementations that print the data stored in XML) options.
* You can request generation of a sample test driver with the <code>--generate-test-driver</code> option. * You can request generation of a sample test driver with the <code>--generate-test-driver</code> option.

Revision as of 12:13, 17 February 2008

This page provides a checklist-like run through the most commonly used XSD command line options. For more details on each option as well as for the complete list of options refer to the XSD command line interface documentation (man pages).

Contents


Common Options

The following options are available for all mappings:

  • You can map any XML Schema namespace (including the no-namespace case and built-in XML Schema namespace) to a custom C++ namespace with the --namespace-map option, for example, --namespace-map http://www.example.com/xmlns/my=Example::My. To place the generated code for a schema without a target namespace into a C++ namespace, use the empty string as XML Schema namespace: --namespace-map =My. To map a set of namespaces at once the --namespace-regex option can be used.
  • To place the generated code into a specific directory, use the --output-dir options, for example, --output-dir src.
  • If you have several schema files and some of them are not self-sufficient (that is, you get XML Schema errors when trying to compile them separately with XSD) or have cyclic dependecies that involve inheritance (that is, you get a C++ error when compiling the generated code with the message saying that the base type is undefined) then you will need to use the file-per-type compilation mode which is turned on with the --file-per-type option. For more information about the file-per-type mode see this blog post.

C++/Tree Mapping Options

The following options are specific to the C++/Tree mapping:

  • If your schema defines several global elements while only some of them can be used as document root elements, then use the --root-element option to reduce the amount of the generated code, for example, --root-element library.
  • If you are using Visual Studio 2005 (8.0) and rely on IntelliSense, then you may want to compile your schemas with the --generate-intellisense option. This option is not needed if you are using Visual Studion 2008 (9.0).
  • If your schema is large and the resulting C++ source file is too big for the C++ compiler to handle (for example, the C++ compiler runs out of memory), then you can use the --parts option to split this file into several files, for example, --parts 4. The file-per-type compilation mode discussed above can also be used to address this issue.

C++/Parser Mapping Options

The following options are specific to the C++/Parser mapping:

  • You can request and suppress generation of the validation code with the --generate-validation and --suppress-validation options, respectively. By default, validation code is generated when a non-validating underlying XML parser is used (Expat) and suppressed otherwise (Xerces-C++). See Section 5.5, "XML Schema Validation" in the C++/Parser Mapping Getting Started Guide for details.
  • You can request generation of sample parser implementations with the --generate-noop-impl (generates empty implementations) and --generate-print-impl (generates implementations that print the data stored in XML) options.
  • You can request generation of a sample test driver with the --generate-test-driver option.
Personal tools