From afebd79d44b75aed3b38e867c65330ba80ddc0ee Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 13 Oct 2009 11:29:26 +0200 Subject: Extended the streaming example It now shows how to perform stream-oriented, partially in-memory XML processing using the C++/Tree mapping. --- examples/cxx/tree/streaming/README | 50 ++++++++++++++++++++++++++++---------- 1 file changed, 37 insertions(+), 13 deletions(-) (limited to 'examples/cxx/tree/streaming/README') diff --git a/examples/cxx/tree/streaming/README b/examples/cxx/tree/streaming/README index 51e5c14..ac7e7f0 100644 --- a/examples/cxx/tree/streaming/README +++ b/examples/cxx/tree/streaming/README @@ -1,22 +1,46 @@ -This example shows how to create an XML document by performing multiple -serializations of its smaller parts. This can be useful when the -document is too large to fit into memory or when the other end needs -to start processing without waiting for the whole document (streaming). +This example shows how to perform stream-oriented, partially in-memory +XML processing using the C++/Tree mapping. With the partially in-memory +parsing and serialization only a part of the object model is in memory at +any given time. With this approach we can process parts of the document +as they become available as well as handle documents that are too large +to fit into memory. The example consists of the following files: -records.xsd - XML Schema which describes a collection of data records. +position.xsd + XML Schema which describes a simple object position vocabulary. The + position is represented as a potentially large series of latitude and + longitude measurements. -records.hxx -records.cxx - C++ types that represent the given vocabulary as well as serialization - functions. These are generated by XSD from records.xsd. +position.xml + Sample object position document. + +position.hxx +position.cxx + C++ types that represent the position vocabulary as well as parsing + and serialization functions. These are generated by XSD from + position.xsd. + +parser.hxx +parser.cxx + Stream-oriented DOM parser implementation that is built on top of the + Xerces-C++ SAX2 parser in the progressive parsing mode. This parser + allows us to parse an XML document as a series of DOM fragments. + +serializer.hxx +serializer.cxx + Stream-oriented DOM serializer implementation that allows us to + serialize an XML Document as a series of object model fragments. driver.cxx - Driver for the example. It progressively serializes one thousand data - record into a file (out.xml). + Driver for the example. It first parses the input file into a series + of DOM fragments which are then parsed into the object model fragments. + The driver prints the information from the document as it becomes + available. The driver then creates a new XML document (out.xml) by + creating and serializing a series of object model fragments. To run the example simply execute: -$ ./driver +$ ./driver position.xml + +The serialization results are written to the out.xml file. -- cgit v1.1