README
1This example shows how to customize the anyType XML Schema built-in
2type to implement preservation of comments stored in XML documents.
3Because anyType is a base type for every generated type, you can use
4this technique to implement custom functionality that spans the
5entire type system. For more information on the C++/Tree mapping
6customization see the C++/Tree Mapping Customization Guide[2].
7
8[2] http://wiki.codesynthesis.com/Tree/Customization_guide
9
10The example consists of the following files:
11
12people.xsd
13 XML Schema definition for a simple person record vocabulary.
14
15people.xml
16 Sample XML instance document.
17
18xml-schema.hxx
19 C++ types for XML Schema built-in types. This header file is generated
20 by XSD using the --generate-xml-schema option. The --custom-type option
21 is also used to customize the xsd:anyType type.
22
23people.hxx
24people.ixx
25people.cxx
26 C++ types that represent the person record vocabulary, a set of
27 parsing functions that convert XML instance documents to a tree-like
28 in-memory object model, and a set of serialization functions that
29 convert the object model back to XML. These are generated by XSD
30 from people.xsd with the --extern-xml-schema option in order to
31 include xml-schema.hxx.
32
33xml-schema-custom.hxx
34 Header file which defines our own xml_schema::type class. It is
35 included at the end of xml-schema.hxx using the --hxx-epilogue
36 option.
37
38xml-schema-custom.cxx
39 Source file which contains the implementation of our xml_schema:type
40 class.
41
42dom-parse.hxx
43dom-parse.cxx
44 Definition and implementation of the parse() function that
45 parses an XML document to a DOM document while preserving
46 XML comments.
47
48driver.cxx
49 Driver for the example. It first calls the above parse() function
50 to parse the input file to a DOM document. It then parses the DOM
51 document to the object model and performs a number of modifications
52 on this object model. Finally, it serializes the modified object
53 model back to XML, including XML comments.
54
55To run the example on the sample XML instance document simply execute:
56
57$ ./driver people.xml
58