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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
This example shows how to parse, store in the object model, and serialize
XML data matched by XML Schema wildcards (any and anyAttribute) using the
Embedded C++/Hybrid.
This example uses the object model as well as parser and serializer
customization mechanisms provided by the C++/Hybrid mapping. For more
information, see Section 4.8, "Customizing the Object Model" and Section
6.1, "Customizing Parsers and Serializers" in the Embedded C++/Hybrid
Mapping Getting Started Guide.
The example consists of the following files:
email.xsd
XML Schema which describes a simple email format with the
extensible envelope type.
email.xml
Sample email message.
email.hxx
email.cxx
email-pskel.hxx
email-pskel.cxx
email-pimpl.hxx
email-pimpl.cxx
email-pskel.hxx
email-pskel.cxx
email-pimpl.hxx
email-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
email.xsd. The --generate-parser, --generate-serializer, and
--generate-aggregate options were used to request the generation of
the parsing and serialization code. The --custom-type option was
used to customize the the envelope class in the object model. The
--custom-parser option was used to customize the envelope_pimpl
parser implementation. The --custom-serializer option was used to
customize the envelope_simpl serializer implementation. Finally,
the --hxx-epilogue option was used to include body.hxx (see below)
at the end of the generated object model header file.
body.hxx
body.cxx
Implementation of the body class. It is used to store the wildcard
data in the body sequence of the customized envelope class.
envelope.hxx
envelope.cxx
Custom envelope type. It uses the generated version as a base and
adds a data member as well as accessor and modifier functions for
the wildcard content.
envelope-pimpl.hxx
envelope-pimpl.cxx
Custom envelope parser implementation. It uses the implementation
generated by the XSD/e compiler as a base and overrides the wildcard
callbacks to parse the wildcard content and store in the body sequence
of the customized envelope object.
envelope-simpl.hxx
envelope-simpl.cxx
Custom envelope serializer implementation. It uses the implementation
generated by the XSD/e compiler as a base and overrides the wildcard
callbacks to serialize the wildcard content stored in the body sequence
of the customized envelope object.
driver.cxx
Driver for the example. It first calls the parser that constructs the
email object from the input XML file. It then prints the content of
the email to STDERR. Finally, the driver creates a reply email and
calls the serializer to serialize it to XML.
To run the example on the sample XML instance document simply execute:
$ ./driver email.xml
The example reads from STDIN if input file is not specified:
$ ./driver <email.xml
|