blob: e185492fd804a10490ef9ced126a077176fa66ff (
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
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 mapping.
This example uses the custom data mechanism to store the wildcard data
in the object model as well as parser and serializer customization to
parse and serialize the wildcard data. 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 'wildcard' example in the examples/cxx/hybrid/custom/ directory shows
how to do the same but using type customization instead of custom data.
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-data option was
used to request addition of custom data to 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.
body.hxx
body.cxx
Implementation of the body class. It is used to store the wildcard
data in the custom data sequence in the envelope class.
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 it as custom data
in the 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 as custom data in
the 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
|