blob: 3d690f52b97d6324a728a35c9f63ab1661489e98 (
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
58
59
60
|
This example shows how to handle XML vocabularies with polymorphic document
root elements in the Embedded C++/Hybrid mapping. For general coverage of
XML Schema polymorphism handling see the polymorphism example.
The example consists of the following files:
supermen.xsd
XML Schema which describes supermen instance documents.
person.xml
superman.xml
batman.xml
Sample XML instance documents.
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 calls the
serializer to serialize the object model back to XML.
To run the example on the sample XML instance documents simply execute:
$ ./driver person.xml
$ ./driver superman.xml
$ ./driver batman.xml
The example reads from STDIN if input file is not specified:
$ ./driver <person.xml
$ ./driver <superman.xml
$ ./driver <batman.xml
|