From 741bfb659caaa771c748d03df26792fab10e5778 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 26 Sep 2023 10:43:31 +0200 Subject: Add XSD and C++ compiler command lines to example READMEs --- xsd-examples/cxx/tree/custom/calendar/README | 37 +++++++++++++++++---- xsd-examples/cxx/tree/custom/comments/README | 42 ++++++++++++++++++----- xsd-examples/cxx/tree/custom/contacts/README | 23 ++++++++++--- xsd-examples/cxx/tree/custom/contacts/buildfile | 10 +++--- xsd-examples/cxx/tree/custom/double/README | 44 +++++++++++++++++++------ xsd-examples/cxx/tree/custom/mixed/README | 30 +++++++++++++---- xsd-examples/cxx/tree/custom/taxonomy/README | 34 +++++++++++++++---- xsd-examples/cxx/tree/custom/wildcard/README | 24 +++++++++++--- 8 files changed, 193 insertions(+), 51 deletions(-) (limited to 'xsd-examples/cxx/tree/custom') diff --git a/xsd-examples/cxx/tree/custom/calendar/README b/xsd-examples/cxx/tree/custom/calendar/README index f7f6989..a4297ba 100644 --- a/xsd-examples/cxx/tree/custom/calendar/README +++ b/xsd-examples/cxx/tree/custom/calendar/README @@ -16,17 +16,29 @@ calendar.xml Sample XML instance document. xml-schema.hxx - C++ types for XML Schema built-in types. This header file is generated - by XSD using the --generate-xml-schema option. The --custom-type option - is also used to customize the xsd:date type. + C++ types for XML Schema built-in types. + + This header file is generated by the XSD compiler in the + --generate-xml-schema mode using the following command line: + + xsd cxx-tree --generate-xml-schema --custom-type date \ + --hxx-epilogue '#include "xml-schema-custom.hxx"' xml-schema.xsd + + The --custom-type option is used to customize the xsd:date type. calendar.hxx calendar.ixx calendar.cxx C++ types that represent the given vocabulary and a set of parsing functions that convert XML instance documents to a tree-like in-memory - object model. These are generated by XSD from calendar.xsd with the - --extern-xml-schema option in order to include xml-schema.hxx. + object model. + + These files are generated by the XSD compiler from calendar.xsd using the + following command line: + + xsd cxx-tree --extern-xml-schema xml-schema.xsd calendar.xsd + + The --extern-xml-schema option is used to include xml-schema.hxx. xml-schema-custom.hxx Header file which defines our own xml_schema::date class. It is @@ -42,6 +54,17 @@ driver.cxx that constructs the object model from the input file. It then prints the calendar events to STDERR. -To run the example on the sample XML instance document simply execute: +To compile and link the example manually from the command line we can use +the following commands (replace 'c++' with your C++ compiler name): + +c++ -DXSD_CXX11 -c calendar.cxx +c++ -DXSD_CXX11 -c xml-schema-custom.cxx +c++ -DXSD_CXX11 -c driver.cxx +c++ -o driver driver.o calendar.o xml-schema-custom.o -lxerces-c + +Note that we need to define the XSD_CXX11 preprocessor macro since the +source code includes libxsd headers directly. + +To run the example on the sample XML instance document execute: -$ ./driver calendar.xml +./driver calendar.xml diff --git a/xsd-examples/cxx/tree/custom/comments/README b/xsd-examples/cxx/tree/custom/comments/README index 8fd69d0..32412db 100644 --- a/xsd-examples/cxx/tree/custom/comments/README +++ b/xsd-examples/cxx/tree/custom/comments/README @@ -16,9 +16,17 @@ people.xml Sample XML instance document. xml-schema.hxx - C++ types for XML Schema built-in types. This header file is generated - by XSD using the --generate-xml-schema option. The --custom-type option - is also used to customize the xsd:anyType type. + C++ types for XML Schema built-in types. + + This header file is generated by by the XSD compiler in the + --generate-xml-schema mode using the following command line: + + xsd cxx-tree --generate-xml-schema \ + --generate-serialization \ + --custom-type anyType=/type_base \ + --hxx-epilogue '#include "xml-schema-custom.hxx"' xml-schema.xsd + + The --custom-type option is used to customize the xsd:anyType type. people.hxx people.ixx @@ -26,9 +34,15 @@ people.cxx C++ types that represent the person record vocabulary, a set of parsing functions that convert XML instance documents to a tree-like in-memory object model, and a set of serialization functions that - convert the object model back to XML. These are generated by XSD - from people.xsd with the --extern-xml-schema option in order to - include xml-schema.hxx. + convert the object model back to XML. + + These files are generated by the XSD compiler from people.xsd using the + following command line: + + xsd cxx-tree --generate-serialization --extern-xml-schema xml-schema.xsd \ + people.xsd + + The --extern-xml-schema option in used to include xml-schema.hxx. xml-schema-custom.hxx Header file which defines our own xml_schema::type class. It is @@ -52,6 +66,18 @@ driver.cxx on this object model. Finally, it serializes the modified object model back to XML, including XML comments. -To run the example on the sample XML instance document simply execute: +To compile and link the example manually from the command line we can use +the following commands (replace 'c++' with your C++ compiler name): + +c++ -DXSD_CXX11 -c people.cxx +c++ -DXSD_CXX11 -c xml-schema-custom.cxx +c++ -DXSD_CXX11 -c dom-parse.cxx +c++ -DXSD_CXX11 -c driver.cxx +c++ -o driver driver.o people.o xml-schema-custom.o dom-parse.o -lxerces-c + +Note that we need to define the XSD_CXX11 preprocessor macro since the +source code includes libxsd headers directly. + +To run the example on the sample XML instance document execute: -$ ./driver people.xml +./driver people.xml diff --git a/xsd-examples/cxx/tree/custom/contacts/README b/xsd-examples/cxx/tree/custom/contacts/README index 072ede3..b2f95eb 100644 --- a/xsd-examples/cxx/tree/custom/contacts/README +++ b/xsd-examples/cxx/tree/custom/contacts/README @@ -19,8 +19,15 @@ contacts.ixx contacts.cxx C++ types that represent the given vocabulary and a set of parsing functions that convert XML instance documents to a tree-like in-memory - object model. These are generated by XSD from contacts.xsd with the - --custom-type option in order to customize the contact type. + object model. + + These files are generated by the XSD compiler from contacts.xsd using the + following command line: + + xsd cxx-tree --custom-type contact=/contact_base \ + --hxx-epilogue '#include "contacts-custom.hxx"' contacts.xsd + + The --custom-type option is used to customize the contact type. contacts-custom.hxx Header file which defines our own contact class by inheriting from the @@ -35,6 +42,14 @@ driver.cxx that constructs the object model from the input file. It then prints the contacts to STDERR. -To run the example on the sample XML instance document simply execute: +To compile and link the example manually from the command line we can use +the following commands (replace 'c++' with your C++ compiler name): + +c++ -c contacts.cxx +c++ -c contacts-custom.cxx +c++ -c driver.cxx +c++ -o driver driver.o contacts.o contacts-custom.o -lxerces-c + +To run the example on the sample XML instance document execute: -$ ./driver contacts.xml +./driver contacts.xml diff --git a/xsd-examples/cxx/tree/custom/contacts/buildfile b/xsd-examples/cxx/tree/custom/contacts/buildfile index e401362..51e9c99 100644 --- a/xsd-examples/cxx/tree/custom/contacts/buildfile +++ b/xsd-examples/cxx/tree/custom/contacts/buildfile @@ -12,11 +12,11 @@ exe{driver}: xml{contacts}: test.input = true <{hxx ixx cxx}{contacts}>: xsd{contacts} $xsd {{ - $xsd cxx-tree \ - --generate-inline \ - --custom-type contact=/contact_base \ - --hxx-epilogue '#include "contacts-custom.hxx"' \ - --output-dir $out_base \ + $xsd cxx-tree \ + --generate-inline \ + --custom-type contact=/contact_base \ + --hxx-epilogue '#include "contacts-custom.hxx"' \ + --output-dir $out_base \ $path($<[0]) }} diff --git a/xsd-examples/cxx/tree/custom/double/README b/xsd-examples/cxx/tree/custom/double/README index 15348d2..bf95104 100644 --- a/xsd-examples/cxx/tree/custom/double/README +++ b/xsd-examples/cxx/tree/custom/double/README @@ -8,7 +8,7 @@ http://wiki.codesynthesis.com/Tree/Customization_guide In this example our schema uses xsd:double to represent a price. There are two potential problems with this choice of a price type. First, xsd:double can be serialized in the scientific notation which would be an unusual way -of representing a price. Second, we would like to limit the number of +of representing a price. Second, we would like to limit the number of fraction digits in our prices to 2. Furthermore, we would like to always have two fraction digits, even if one or both of them are zeros, for example: 12.99, 12.90, 12.00. @@ -42,21 +42,45 @@ double-custom.cxx file described below. xml-schema.hxx - C++ types for XML Schema built-in types. This header file is generated - by the XSD compiler using the --generate-xml-schema option. The - --custom-type option is used to customize the xsd:double type. The - --hxx-epilogue option is used to include the double-custom.hxx file - at the end of this file. + C++ types for XML Schema built-in types. + + This header file is generated by the XSD compiler in the + --generate-xml-schema mode using the following command line: + + xsd cxx-tree --generate-xml-schema --generate-serialization \ + --custom-type double=double \ + --hxx-epilogue '#include "double-custom.hxx"' xml-schema.xsd + + The --custom-type option is used to customize the xsd:double type. The + --hxx-epilogue option is used to include the double-custom.hxx file at + the end of this file. order.hxx order.cxx - C++ types generated from order.xsd. The --extern-xml-schema option - is used to include xml-schema.hxx into order.hxx. + C++ types are generated by the XSD compiler from order.xsd using the + following command line: + + xsd cxx-tree --generate-serialization --extern-xml-schema xml-schema.xsd \ + order.xsd + + The --extern-xml-schema option is used to include xml-schema.hxx into + order.hxx. driver.cxx Test driver for the example. It creates a sample order and then writes it to XML to test the custom xsd:double serialization code. -To run the example simply execute: +To compile and link the example manually from the command line we can use +the following commands (replace 'c++' with your C++ compiler name): + +c++ -DXSD_CXX11 -c order.cxx +c++ -DXSD_CXX11 -c double-custom.cxx +c++ -DXSD_CXX11 -c driver.cxx +c++ -o driver driver.o order.o double-custom.o -lxerces-c + +Note that we need to define the XSD_CXX11 preprocessor macro since the +source code includes libxsd headers directly. + +To run the example execute: -$ ./driver +./driver diff --git a/xsd-examples/cxx/tree/custom/mixed/README b/xsd-examples/cxx/tree/custom/mixed/README index 7b56812..8f7bd13 100644 --- a/xsd-examples/cxx/tree/custom/mixed/README +++ b/xsd-examples/cxx/tree/custom/mixed/README @@ -1,6 +1,6 @@ This example shows how to use type customization to parse and serialize -mixed content. The example achieves this by customizing the type with -the mixed content model to include a DOM document that stores the data +mixed content. The example achieves this by customizing the type with +the mixed content model to include a DOM document that stores the data as a raw XML representation. The customized type also provides its own parsing constructor and serialization operator where the mixed content is extracted from and inserted back to DOM, respectively. The use of @@ -28,8 +28,15 @@ people.cxx C++ types that represent the given vocabulary, a set of parsing functions that convert XML instance documents to a tree-like in-memory object model, and a set of serialization functions that convert the - object model back to XML. These are generated by XSD from people.xsd - with the --custom-type option in order to customize the bio type. + object model back to XML. + + These files are generated by the XSD compiler from people.xsd using the + following command line: + + xsd cxx-tree --generate-serialization --custom-type bio=/bio_base \ + --hxx-epilogue '#include "people-custom.hxx"' people.xsd + + The --custom-type option is used to customize the bio type. people-custom.hxx Header file which defines our own bio class by inheriting from the @@ -45,6 +52,17 @@ driver.cxx the data to STDERR, including the bio information converted to text. Finally, the driver serializes the object model back to XML. -To run the example on the sample XML instance document simply execute: +To compile and link the example manually from the command line we can use +the following commands (replace 'c++' with your C++ compiler name): + +c++ -DXSD_CXX11 -c people.cxx +c++ -DXSD_CXX11 -c people-custom.cxx +c++ -DXSD_CXX11 -c driver.cxx +c++ -o driver driver.o people.o people-custom.o -lxerces-c + +Note that we need to define the XSD_CXX11 preprocessor macro since the +source code includes libxsd headers directly. + +To run the example on the sample XML instance document execute: -$ ./driver people.xml +./driver people.xml diff --git a/xsd-examples/cxx/tree/custom/taxonomy/README b/xsd-examples/cxx/tree/custom/taxonomy/README index c2e425a..3296508 100644 --- a/xsd-examples/cxx/tree/custom/taxonomy/README +++ b/xsd-examples/cxx/tree/custom/taxonomy/README @@ -20,12 +20,24 @@ people.ixx people.cxx C++ types that represent the given vocabulary and a set of parsing functions that convert XML instance documents to a tree-like in-memory - object model. These are generated by XSD from people.xsd with the - --custom-type option in order to customize the person, superman, and + object model. + + These files are generated by the XSD compiler from people.xsd using the + following command line: + + xsd cxx-tree --generate-forward --generate-polymorphic \ + --polymorphic-type person \ + --custom-type "person=person_impl/person_base" \ + --custom-type "superman=superman_impl/superman_base" \ + --custom-type "batman=batman_impl/batman_base" \ + --fwd-prologue '#include "people-custom-fwd.hxx"' \ + --hxx-prologue '#include "people-custom.hxx"' people.xsd + + The --custom-type option is used to customize the person, superman, and batman types. Generation of the people-fwd.hxx forward declaration - file is requested with the --generate-forward option. Note also that - we use the --generate-polymorphic command line option as well as - --polymorphic-type to mark the type hierarchy starting with the + file is requested with the --generate-forward option. Note also that + we use the --generate-polymorphic command line option as well as + --polymorphic-type to mark the type hierarchy starting with the person type as polymorphic. people-custom-fwd.hxx @@ -48,6 +60,14 @@ driver.cxx that constructs the object model from the input file. It then prints the database to STDERR. -To run the example on the sample XML instance document simply execute: +To compile and link the example manually from the command line we can use +the following commands (replace 'c++' with your C++ compiler name): + +c++ -c people.cxx +c++ -c people-custom.cxx +c++ -c driver.cxx +c++ -o driver driver.o people.o people-custom.o -lxerces-c + +To run the example on the sample XML instance document execute: -$ ./driver people.xml +./driver people.xml diff --git a/xsd-examples/cxx/tree/custom/wildcard/README b/xsd-examples/cxx/tree/custom/wildcard/README index 70eaea4..8b5b2f0 100644 --- a/xsd-examples/cxx/tree/custom/wildcard/README +++ b/xsd-examples/cxx/tree/custom/wildcard/README @@ -23,8 +23,16 @@ wildcard.cxx C++ types that represent the given vocabulary, a set of parsing functions that convert XML instance documents to a tree-like in-memory object model, and a set of serialization functions that convert the - object model back to XML. These are generated by XSD from wildcard.xsd - with the --custom-type option in order to customize the data type. + object model back to XML. + + These files are generated by the XSD compiler from wildcard.xsd using + the following command line: + + xsd cxx-tree --generate-serialization --generate-ostream \ + --custom-type data=/data_base \ + --hxx-epilogue '#include "wildcard-custom.hxx"' wildcard.xsd + + The --custom-type option is used to customize the data type. wildcard-custom.hxx Header file which defines our own data class by inheriting from the @@ -40,6 +48,14 @@ driver.cxx the data to STDERR, including the extra attribute. Finally, the driver serializes the object model back to XML. -To run the example on the sample XML instance document simply execute: +To compile and link the example manually from the command line we can use +the following commands (replace 'c++' with your C++ compiler name): + +c++ -c wildcard.cxx +c++ -c wildcard-custom.cxx +c++ -c driver.cxx +c++ -o driver driver.o wildcard.o wildcard-custom.o -lxerces-c + +To run the example on the sample XML instance document execute: -$ ./driver wildcard.xml +./driver wildcard.xml -- cgit v1.1