summaryrefslogtreecommitdiff
path: root/xsd-examples/cxx/tree/custom/double/README
diff options
context:
space:
mode:
Diffstat (limited to 'xsd-examples/cxx/tree/custom/double/README')
-rw-r--r--xsd-examples/cxx/tree/custom/double/README44
1 files changed, 34 insertions, 10 deletions
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