blob: d772ab808df9a93edc76b47fb2c9b136aca65e69 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
This example shows how to use the sample implementation and test
driver generation feature of the C++/Parser mapping. This example
does not have any hand-written C++ code; everything is generated
by the XSD compiler.
The example consists of the following files:
library.xsd
XML Schema which describes a library of books.
library.xml
Sample XML instance document.
library-pskel.hxx
library-pskel.cxx
Parser skeletons generated by the XSD compiler from library.xsd using
the following command line:
xsd cxx-parser --generate-print-impl --generate-test-driver library.xsd
Or if using Expat instead of Xerces-C++ as the underlying XML parser:
xsd cxx-parser --xml-parser=expat --generate-print-impl \
--generate-test-driver library.xsd
library-pimpl.hxx
library-pimpl.cxx
Sample parser implementations that print the XML data to STDOUT.
These are also generated by the above XSD command (requested with
the --generate-print-impl option).
library-driver.cxx
Sample driver for the example. It is also generated by the above
XSD command (requested with the --generate-test-driver option).
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 library-pskel.cxx
c++ -c library-pimpl.cxx
c++ -c library-driver.cxx
c++ -o driver library-driver.o library-pskel.o library-pimpl.o -lxerces-c
Or if using Expat as the underlying XML parser:
c++ -o driver library-driver.o library-pskel.o library-pimpl.o -lexpat
To run the example on the sample XML instance document execute:
./driver library.xml
|