blob: 2e00636aeadfe196d32dcb180698f8b74781cf97 (
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
51
52
53
54
55
56
57
|
This example shows how to handle XML vocabularies that use the XML
Schema polymorphism features such as the xsi:type attribute and
substitution groups in the Embedded C++/Hybrid mapping. The case
where xsi:type or substitution groups are used on document root
elements is covered in the polyroot examples.
The example consists of the following files:
supermen.xsd
XML Schema which describes supermen instance documents.
supermen.xml
Sample XML instance document.
supermen.hxx
supermen.cxx
supermen-pskel.hxx
supermen-pskel.cxx
supermen-pimpl.hxx
supermen-pimpl.cxx
supermen-pskel.hxx
supermen-pskel.cxx
supermen-pimpl.hxx
supermen-pimpl.cxx
Object model (the first pair of files), parser skeletons (the
second pair), parser implementations (the third pair), serializer
skeletons (the fourth pair), and serializer implementations (the
fifth pair). These files are generated by the XSD/e compiler from
supermen.xsd. The --generate-parser, --generate-serializer, and
--generate-aggregate options were used to request the generation
of the parsing and serialization code. The --generate-polymorphic
option was used to request the generation of the polymorphism-aware
code. Since our vocabulary uses substitution groups, the XSD/e
compiler is able to automatically determine which type hierarchy is
polymorphic (otherwise we would have had to use the --polymorphic-type
option). The --generate-typeinfo option was used to request the
generation of custom type information for polymorphic object model
types. Finally, the --root-element option was used to specify the
document root element.
driver.cxx
Driver for the example. It first calls the parser that constructs
the object model from the input XML file. It then prints the content
of the object model to STDERR at which point it determines the actual
(dynamic) types of polymorphic objects. Finally, the driver modifies
the object model by adding another polymorphic instance and calls the
serializer to serialize it back to XML.
To run the example on the sample XML instance document simply execute:
$ ./driver supermen.xml
The example reads from STDIN if input file is not specified:
$ ./driver <supermen.xml
|