Another capability that is related to -genTestis the capability to generate sample reader and writer programs. These can act as guides or templates in developing more advanced applications.
The -genReaderoption causes a reader program (reader.c) to be generated. This program will read data from a file containing an XML document and decode the document into a corresponding data structure. The data structure to be used will either be chosen randomly from the provided schema file, or the - usepduoption may be used to select the global element to be used.
The -genWriteroption causes a writer program (writer.c) to be generated. The global element to be used as the basis for this program can be selected using -usepudoption as was done for the reader above. If -genTestwas specified at the same time as -genWriter, a section will be added to the writer to populate a data structure with test data for encoding. If -genTestwas not specified, a "TODO" section is added to the writer to allow the user to add their own code to populate a variable of the type to be encoded.
The -genRWTestoption causes a read/write program to be generated. This reads in a document of a given XML schema type (as above, this may be specified using -usepdu), decodes it, and then reencodes iand writes the document back out. This can be useful for doing transformations on a document such as automatically changing the values of certain fields. It is also useful for round-trip testing.
The -exicompressand -zipoptions can be used in conjunction with -genReaderand -genWriterswitches to produce programs that will read and write documents in compressed form. The -exicompressoption causes schemaless EXI encoding to be done on the document as specified in the first public working draft of the W3C Efficient XML Interchange specification ( http://www.w3.org/TR/exi/). Also, -c14ncan be used to produce a writer program that will output an XML document in canonical form.